@perspective-dev/viewer-charts 5.2.0 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/cdn/perspective-viewer-charts.js +1 -2
  2. package/dist/cdn/perspective-viewer-charts.js.map +4 -4
  3. package/dist/esm/axis/legend.d.ts +53 -5
  4. package/dist/esm/axis/map-ticks.d.ts +15 -0
  5. package/dist/esm/charts/candlestick/candlestick-interact.d.ts +2 -6
  6. package/dist/esm/charts/candlestick/candlestick-render.d.ts +3 -0
  7. package/dist/esm/charts/cartesian/cartesian.d.ts +7 -0
  8. package/dist/esm/charts/cartesian/glyph.d.ts +2 -1
  9. package/dist/esm/charts/cartesian/glyphs/density.d.ts +2 -1
  10. package/dist/esm/charts/cartesian/glyphs/lines.d.ts +2 -1
  11. package/dist/esm/charts/cartesian/glyphs/points.d.ts +2 -1
  12. package/dist/esm/charts/cartesian/tooltip-lines.d.ts +1 -1
  13. package/dist/esm/charts/chart-base.d.ts +24 -9
  14. package/dist/esm/charts/chart.d.ts +81 -6
  15. package/dist/esm/charts/common/category-axis-resolver.d.ts +1 -1
  16. package/dist/esm/charts/common/draw-tooltip-box.d.ts +2 -1
  17. package/dist/esm/charts/common/tree-chart.d.ts +1 -0
  18. package/dist/esm/charts/common/tree-interact.d.ts +1 -1
  19. package/dist/esm/charts/heatmap/heatmap.d.ts +1 -0
  20. package/dist/esm/charts/series/series-build.d.ts +7 -0
  21. package/dist/esm/charts/series/series-interact.d.ts +1 -1
  22. package/dist/esm/charts/series/series-type.d.ts +18 -0
  23. package/dist/esm/charts/series/series.d.ts +10 -1
  24. package/dist/esm/charts/sunburst/sunburst-render.d.ts +4 -0
  25. package/dist/esm/index.d.ts +2 -0
  26. package/dist/esm/interaction/axis-indicators.d.ts +11 -0
  27. package/dist/esm/interaction/host-sink-dom.d.ts +3 -2
  28. package/dist/esm/interaction/host-sink-message.d.ts +3 -2
  29. package/dist/esm/interaction/lazy-tooltip.d.ts +2 -2
  30. package/dist/esm/interaction/legend-controller.d.ts +246 -0
  31. package/dist/esm/interaction/tooltip-controller.d.ts +20 -95
  32. package/dist/esm/interaction/tooltip-grid.d.ts +33 -0
  33. package/dist/esm/layout/facet-grid.d.ts +6 -0
  34. package/dist/esm/layout/ticks.d.ts +1 -0
  35. package/dist/esm/map/tile-source.d.ts +77 -8
  36. package/dist/esm/perspective-viewer-charts.js +1 -2
  37. package/dist/esm/perspective-viewer-charts.js.map +4 -4
  38. package/dist/esm/plugin/charts.d.ts +2 -0
  39. package/dist/esm/plugin/format-defaults.d.ts +9 -0
  40. package/dist/esm/plugin/plugin.d.ts +28 -1
  41. package/dist/esm/theme/gradient.d.ts +32 -0
  42. package/dist/esm/theme/overrides.d.ts +19 -0
  43. package/dist/esm/transport/protocol.d.ts +58 -5
  44. package/dist/esm/transport/renderer-transport.d.ts +3 -0
  45. package/dist/esm/utils/css.d.ts +4 -0
  46. package/dist/esm/worker/renderer.worker.d.ts +46 -1
  47. package/package.json +1 -1
  48. package/src/css/perspective-viewer-charts.css +0 -1
  49. package/src/ts/axis/bar-axis.ts +2 -7
  50. package/src/ts/axis/legend.ts +351 -24
  51. package/src/ts/axis/map-ticks.ts +94 -0
  52. package/src/ts/axis/numeric-axis.ts +2 -9
  53. package/src/ts/charts/candlestick/candlestick-build.ts +1 -0
  54. package/src/ts/charts/candlestick/candlestick-interact.ts +46 -40
  55. package/src/ts/charts/candlestick/candlestick-render.ts +81 -10
  56. package/src/ts/charts/candlestick/candlestick.ts +4 -3
  57. package/src/ts/charts/cartesian/cartesian-interact.ts +9 -3
  58. package/src/ts/charts/cartesian/cartesian-render.ts +374 -75
  59. package/src/ts/charts/cartesian/cartesian.ts +13 -0
  60. package/src/ts/charts/cartesian/glyph.ts +6 -2
  61. package/src/ts/charts/cartesian/glyphs/density.ts +2 -2
  62. package/src/ts/charts/cartesian/glyphs/lines.ts +15 -11
  63. package/src/ts/charts/cartesian/glyphs/points.ts +9 -5
  64. package/src/ts/charts/cartesian/tooltip-lines.ts +8 -8
  65. package/src/ts/charts/chart-base.ts +76 -42
  66. package/src/ts/charts/chart.ts +111 -7
  67. package/src/ts/charts/common/category-axis-resolver.ts +44 -5
  68. package/src/ts/charts/common/draw-tooltip-box.ts +13 -30
  69. package/src/ts/charts/common/tree-chart.ts +4 -0
  70. package/src/ts/charts/common/tree-chrome.ts +102 -23
  71. package/src/ts/charts/common/tree-interact.ts +18 -17
  72. package/src/ts/charts/heatmap/heatmap-build.ts +7 -1
  73. package/src/ts/charts/heatmap/heatmap-interact.ts +75 -8
  74. package/src/ts/charts/heatmap/heatmap-render.ts +105 -24
  75. package/src/ts/charts/heatmap/heatmap.ts +8 -3
  76. package/src/ts/charts/map/map.ts +3 -5
  77. package/src/ts/charts/series/series-build.ts +15 -2
  78. package/src/ts/charts/series/series-interact.ts +14 -24
  79. package/src/ts/charts/series/series-render.ts +310 -132
  80. package/src/ts/charts/series/series-type.ts +65 -0
  81. package/src/ts/charts/series/series.ts +31 -8
  82. package/src/ts/charts/sunburst/sunburst-render.ts +16 -1
  83. package/src/ts/charts/treemap/treemap-render.ts +12 -1
  84. package/src/ts/data/view-reader.ts +1 -4
  85. package/src/ts/index.ts +2 -0
  86. package/src/ts/interaction/axis-indicators.ts +137 -0
  87. package/src/ts/interaction/host-sink-dom.ts +66 -2
  88. package/src/ts/interaction/host-sink-message.ts +8 -2
  89. package/src/ts/interaction/lazy-tooltip.ts +5 -5
  90. package/src/ts/interaction/legend-controller.ts +1084 -0
  91. package/src/ts/interaction/tooltip-controller.ts +43 -131
  92. package/src/ts/interaction/tooltip-grid.ts +187 -0
  93. package/src/ts/layout/facet-grid.ts +8 -1
  94. package/src/ts/layout/ticks.ts +48 -12
  95. package/src/ts/map/tile-loader.ts +16 -1
  96. package/src/ts/map/tile-source.ts +199 -53
  97. package/src/ts/map/tile-sources.json +18 -0
  98. package/src/ts/plugin/charts.ts +40 -6
  99. package/src/ts/plugin/format-defaults.ts +37 -0
  100. package/src/ts/plugin/plugin.ts +330 -76
  101. package/src/ts/shaders/line.vert.glsl +5 -2
  102. package/src/ts/shaders/scatter.vert.glsl +0 -7
  103. package/src/ts/theme/gradient.ts +265 -1
  104. package/src/ts/theme/overrides.ts +76 -0
  105. package/src/ts/transport/protocol.ts +60 -4
  106. package/src/ts/transport/renderer-transport.ts +107 -14
  107. package/src/ts/utils/css.ts +12 -0
  108. package/src/ts/worker/dispatch.ts +6 -2
  109. package/src/ts/worker/renderer.worker.ts +191 -7
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../../src/ts/plugin/charts.ts", "../../src/css/perspective-viewer-charts.css", "../../src/ts/charts/chart.ts", "../../src/ts/interaction/raw-event-forwarder.ts", "../../src/ts/event-detail.ts", "../../src/ts/theme/theme-snapshot.ts", "../../src/ts/utils/font-snapshot.ts", "../../src/ts/interaction/host-sink-dom.ts", "../../src/ts/config.ts", "worker:../worker/renderer.js", "worker-stub:../worker/renderer.worker.js", "../../src/ts/transport/renderer-transport.ts", "../../src/ts/plugin/plugin.ts", "../../src/ts/index.ts"],
4
- "sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { PluginConfig } from \"../charts/chart\";\n\nexport type ChartType = \"bar\" | \"line\" | \"scatter\" | \"area\";\n\nexport type PluginChartType = ChartType | \"candlestick\" | \"ohlc\";\n\n/**\n * Subset of `PluginConfig` keys that a chart impl actually consumes.\n * Drives `plugin_config_schema()` filtering \u2014 the host only renders\n * the controls listed here, and `plugin.restore({ plugin_config })`\n * still hands the full struct to the worker (other keys are inert).\n */\nexport type PluginConfigField = keyof PluginConfig;\n\nexport interface ChartTypeConfig {\n name: string;\n tag: string;\n category: string;\n selectMode: \"select\" | \"toggle\";\n initial: {\n count: number;\n names: string[];\n };\n max_cells: number;\n max_columns: number;\n default_chart_type?: PluginChartType;\n\n /**\n * Plugin-config keys this chart type renders controls for. Empty\n * for plugins with no global settings (heatmap / treemap /\n * sunburst). See {@link PluginConfig} for field semantics.\n */\n applicable_plugin_fields: readonly PluginConfigField[];\n\n /**\n * What `group_by` DRAWS in this chart, e.g. `\"X Axis\"` for the\n * Y-series charts. Omitted where the field has no visual role of\n * its own and is a plain aggregation key \u2014 the X/Y and map charts,\n * whose axes both come from `columns`.\n *\n * The `group_by` counterpart of `initial.names`: one declaration\n * says what every view field draws, so the settings UI's labels and\n * the agent's `list_plugins` contract read the same source instead\n * of restating the mapping.\n */\n group_by_role?: string;\n\n /** What `split_by` DRAWS in this chart. See {@link group_by_role}. */\n split_by_role?: string;\n\n /**\n * Set on the charts that CONNECT their points in row order, so the\n * view's row order shows up in the drawing: without a `sort` the\n * line follows the table's natural order, which reads as a tangle\n * unless the rows already arrive ordered along the X axis. The point\n * charts (scatter, density) are unaffected, and a pre-ordered table\n * needs no `sort` \u2014 which is why this is declared per chart rather\n * than inferred from an empty `sort`.\n */\n connects_row_order?: boolean;\n\n /**\n * Per-chart-type overrides for `DEFAULT_PLUGIN_CONFIG`. Used when a\n * field's sensible default differs by chart family \u2014 currently\n * `include_zero` (true for Y Bar / Y Area / X Bar, false for line\n * / scatter / cartesian / financial) and `facet_mode` (\"overlay\"\n * for the band-pipeline families \u2014 series / financial \u2014 whose\n * historical split_by rendering is the single stacked/colored\n * plot; \"grid\" elsewhere). Applied at schema generation and at\n * `restore({})` so the effective default matches the surfaced UI\n * default.\n */\n plugin_field_defaults?: Partial<PluginConfig>;\n}\n\nconst SERIES = \"Series Charts\";\nconst CART = \"Cartesian Charts\";\nconst HIER = \"Hierarchical Charts\";\nconst FIN = \"Financial Charts\";\nconst MAP = \"Map Charts\";\nconst X_AXIS = [\"X Axis\"];\nconst Y_AXIS = [\"Y Axis\"];\nconst SELECT = \"select\";\nconst TOGGLE = \"toggle\";\n\nconst DEFAULT_MAX_CELLS = 2_000_000;\nconst DEFAULT_MAX_COLUMNS = 10_000;\n\n// Plugin-config field sets, by chart family.\n//\n// Series charts paint bars / lines / scatter / area glyphs (selected\n// per-column via `chart_type`), so the union covers every glyph that\n// might appear. `auto_alt_y_axis` + `series_zoom_mode` are Series-only.\nconst SERIES_FIELDS: readonly PluginConfigField[] = [\n \"auto_alt_y_axis\",\n \"facet_mode\",\n \"series_zoom_mode\",\n \"include_zero\",\n \"domain_mode\",\n \"line_width_px\",\n \"point_size_px\",\n \"band_inner_frac\",\n \"bar_inner_pad\",\n];\n\n// The band pipeline's historical split_by rendering is a single plot\n// (splits stacked / colored in place), so the series family defaults\n// `facet_mode` to \"overlay\" \u2014 grid faceting is the opt-in. Cartesian\n// charts keep the global \"grid\" default from `DEFAULT_PLUGIN_CONFIG`.\nconst SERIES_DEFAULTS: Partial<PluginConfig> = { facet_mode: \"overlay\" };\n\n// Bar / area series glyphs grow from the zero baseline, so the value\n// axis must enclose 0 to render correctly. Line / scatter glyphs have\n// no such constraint \u2014 their default `include_zero` stays `false`.\nconst ZERO_ANCHORED_DEFAULTS: Partial<PluginConfig> = {\n ...SERIES_DEFAULTS,\n include_zero: true,\n};\n\n// Pure Cartesian (X/Y Scatter, X/Y Line) \u2014 no categorical axis, so no\n// band geometry; gets the facet-routing variant of zoom_mode.\nconst CARTESIAN_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"line_width_px\",\n \"point_size_px\",\n];\n\n// Candlestick/OHLC share the categorical-X build pipeline (band slots)\n// and add their two stroke widths.\nconst FIN_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"series_zoom_mode\",\n \"domain_mode\",\n \"band_inner_frac\",\n \"bar_inner_pad\",\n \"wick_width_px\",\n \"ohlc_line_width_px\",\n];\n\n// Hierarchical \u2014 none of the listed fields apply.\nconst NO_FIELDS: readonly PluginConfigField[] = [];\n\n// Heatmap\nconst HEATMAP_FIELDS: readonly PluginConfigField[] = [\"facet_zoom_mode\"];\n\n// Map \u2014 reuses the cartesian build pipeline with a Mercator\n// projection hook. Carries the basemap controls (`map_tile_provider`,\n// `map_tile_alpha`) plus the relevant glyph-styling fields the\n// underlying chart type already uses. Density-on-map adds the four\n// gradient knobs on top.\nconst MAP_BASE_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"map_tile_provider\",\n \"map_tile_alpha\",\n];\nconst MAP_SCATTER_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"point_size_px\",\n];\nconst MAP_LINE_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"line_width_px\",\n];\nconst MAP_DENSITY_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"gradient_color_mode\",\n \"gradient_radius_px\",\n \"gradient_intensity\",\n \"gradient_heat_max\",\n];\n\n// Density \u2014 shares the cartesian build pipeline (X/Y numeric\n// with an optional Color column), then routes through the density-field\n// glyph. Reuses the cartesian facet/zoom controls and adds the three\n// shader-specific knobs.\nconst DENSITY_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"gradient_color_mode\",\n \"gradient_radius_px\",\n \"gradient_intensity\",\n \"gradient_heat_max\",\n];\n\nfunction make(\n name: string,\n tag: string,\n category: string,\n selectMode: \"select\" | \"toggle\",\n count: number,\n names: readonly string[],\n applicable_plugin_fields: readonly PluginConfigField[],\n overrides?: Partial<\n Pick<\n ChartTypeConfig,\n | \"max_cells\"\n | \"max_columns\"\n | \"default_chart_type\"\n | \"plugin_field_defaults\"\n | \"group_by_role\"\n | \"split_by_role\"\n | \"connects_row_order\"\n >\n >,\n): ChartTypeConfig {\n return {\n name,\n tag,\n category,\n selectMode,\n initial: { count, names: names as string[] },\n max_cells: overrides?.max_cells ?? DEFAULT_MAX_CELLS,\n max_columns: overrides?.max_columns ?? DEFAULT_MAX_COLUMNS,\n applicable_plugin_fields,\n ...(overrides?.default_chart_type\n ? { default_chart_type: overrides.default_chart_type }\n : {}),\n ...(overrides?.plugin_field_defaults\n ? { plugin_field_defaults: overrides.plugin_field_defaults }\n : {}),\n ...(overrides?.group_by_role\n ? { group_by_role: overrides.group_by_role }\n : {}),\n ...(overrides?.split_by_role\n ? { split_by_role: overrides.split_by_role }\n : {}),\n ...(overrides?.connects_row_order\n ? { connects_row_order: overrides.connects_row_order }\n : {}),\n };\n}\n\nconst FIN_NAMES = [\"Open\", \"Close\", \"High\", \"Low\", \"Tooltip\"];\nconst HIER_NAMES = [\"Size\", \"Color\", \"Tooltip\"];\n\nconst SERIES_Y_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Series\" };\nconst SERIES_X_ROLES = { group_by_role: \"Y Axis\", split_by_role: \"Series\" };\nconst CART_ROLES = {};\nconst HIER_ROLES = { group_by_role: \"Hierarchy\", split_by_role: \"Facets\" };\nconst HEATMAP_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Y Axis\" };\nconst FIN_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Series\" };\nconst MAP_ROLES = {};\n\nconst CHARTS: ChartTypeConfig[] = [\n make(\"X Bar\", \"x-bar\", SERIES, SELECT, 1, X_AXIS, SERIES_FIELDS, {\n ...SERIES_X_ROLES,\n default_chart_type: \"bar\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\"Y Bar\", \"y-bar\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"bar\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\"Y Line\", \"y-line\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"line\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"Y Scatter\", \"y-scatter\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"scatter\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"Y Area\", \"y-area\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"area\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\n \"X/Y Scatter\",\n \"scatter\",\n CART,\n TOGGLE,\n 2,\n [\"X Axis\", \"Y Axis\", \"Color\", \"Size\", \"Label\", \"Tooltip\"],\n CARTESIAN_FIELDS,\n { ...CART_ROLES },\n ),\n make(\n \"X/Y Line\",\n \"line\",\n CART,\n SELECT,\n 2,\n [\"X Axis\", \"Y Axis\", \"Tooltip\"],\n CARTESIAN_FIELDS,\n { ...CART_ROLES, connects_row_order: true },\n ),\n make(\n \"Density\",\n \"density\",\n CART,\n TOGGLE,\n 2,\n [\"X Axis\", \"Y Axis\", \"Color\", \"Tooltip\"],\n DENSITY_FIELDS,\n { ...CART_ROLES },\n ),\n make(\"Treemap\", \"treemap\", HIER, TOGGLE, 1, HIER_NAMES, NO_FIELDS, {\n ...HIER_ROLES,\n }),\n make(\"Sunburst\", \"sunburst\", HIER, TOGGLE, 1, HIER_NAMES, NO_FIELDS, {\n ...HIER_ROLES,\n }),\n make(\"Heatmap\", \"heatmap\", HIER, SELECT, 1, [\"Color\"], HEATMAP_FIELDS, {\n ...HEATMAP_ROLES,\n }),\n make(\"Candlestick\", \"candlestick\", FIN, TOGGLE, 1, FIN_NAMES, FIN_FIELDS, {\n ...FIN_ROLES,\n default_chart_type: \"candlestick\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"OHLC\", \"ohlc\", FIN, TOGGLE, 1, FIN_NAMES, FIN_FIELDS, {\n ...FIN_ROLES,\n default_chart_type: \"ohlc\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\n \"Map Scatter\",\n \"map-scatter\",\n MAP,\n TOGGLE,\n 2,\n [\"Longitude\", \"Latitude\", \"Color\", \"Size\", \"Label\", \"Tooltip\"],\n MAP_SCATTER_FIELDS,\n { ...MAP_ROLES },\n ),\n make(\n \"Map Line\",\n \"map-line\",\n MAP,\n SELECT,\n 2,\n [\"Longitude\", \"Latitude\", \"Tooltip\"],\n MAP_LINE_FIELDS,\n { ...MAP_ROLES, connects_row_order: true },\n ),\n make(\n \"Map Density\",\n \"map-density\",\n MAP,\n TOGGLE,\n 2,\n [\"Longitude\", \"Latitude\", \"Color\", \"Tooltip\"],\n MAP_DENSITY_FIELDS,\n { ...MAP_ROLES },\n ),\n];\n\nexport default CHARTS;\n", ":host{--psp-charts--tooltip--color:var(--psp--color);--psp-charts--tooltip--background:var(--psp--background-color);--psp-charts--tooltip--border-color:var(--psp-inactive--border-color);width:100%;height:100%;font-family:inherit;display:block;position:relative;overflow:hidden}.webgl-container{position:absolute;inset:6px}.webgl-canvas{width:100%;height:100%;position:absolute;top:0;left:0}.webgl-gridlines,.webgl-chrome{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.zoom-controls{z-index:2;pointer-events:auto;display:none;position:absolute;top:8px;left:50%;transform:translate(-50%)}.zoom-controls.visible{gap:6px;display:flex}.zoom-reset{background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);font:11px var(--psp-charts--font-family);cursor:pointer;opacity:.7;border-radius:4px;padding:4px 12px;transition:opacity .15s}.zoom-reset:hover{opacity:1}.webgl-tooltip{pointer-events:auto;font:11px var(--psp-charts--font-family);background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);white-space:pre;z-index:10;border-radius:3px;padding:3px;line-height:16px;position:absolute;overflow-y:auto}", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { View } from \"@perspective-dev/client\";\nimport type { ColumnDataMap } from \"../data/view-reader\";\nimport type { WebGLContextManager } from \"../webgl/context-manager\";\nimport type { ZoomController } from \"../interaction/zoom-controller\";\nimport type { HostSink } from \"../interaction/tooltip-controller\";\n\nexport interface ChartImplementation {\n uploadAndRender(\n glManager: WebGLContextManager,\n columns: ColumnDataMap,\n startRow: number,\n endRow: number,\n ): void;\n\n /**\n * The single render entrypoint. Every render-triggering caller \u2014\n * upload chunks, zoom / pan, resize, theme invalidation,\n * host-driven redraws \u2014 calls this. Routes through the\n * module-level scheduler ([render/scheduler.ts]) so concurrent\n * calls collapse to one `_fullRender` per RAF and the host\n * blitter receives one bitmap per frame per chart.\n *\n * The returned promise resolves after this entry's `_fullRender`\n * + `awaitGpuFence` + `endFrame` chain completes \u2014 independent\n * of other charts in the same RAF, which run their fence waits\n * in parallel.\n *\n * The synchronous-render bypass for `snapshotPng` (calls\n * `_fullRender` directly, skips `endFrame`) is the only\n * sanctioned exception and lives inside the worker renderer.\n */\n requestRender(glManager: WebGLContextManager): Promise<void>;\n\n /**\n * The chart-specific GL frame builder. Submits the GL draw commands\n * and stashes the frame's 2D-canvas draws (gridlines + chrome) for\n * the scheduler to flush after `awaitGpuFence`. The scheduler wraps\n * this with fence + 2D flush + `endFrame`; callers must not invoke\n * it directly \u2014 `snapshotPng` uses {@link renderFrameSync} instead.\n */\n _fullRender(glManager: WebGLContextManager): void;\n\n /**\n * Synchronous full frame (GL + 2D) for the `snapshotPng` bypass,\n * which sits outside the scheduler and needs the gridline/chrome\n * canvases painted before compositing. Runs the GL pass then flushes\n * the deferred 2D draws immediately, skipping the fence split and\n * `endFrame` so the GL backbuffer stays intact for `gl.readPixels`.\n */\n renderFrameSync(glManager: WebGLContextManager): void;\n\n /**\n * Hand the current View to the chart so it can make on-demand\n * per-row queries (for lazy tooltip column lookups). Called on\n * every `draw`; the chart disposes any prior fetcher and clears\n * dependent UI (pinned tooltip) so stale rows never surface.\n *\n * TODO: pinned tooltips are dismissed on view update today. A\n * future enhancement is to keep a pinned tooltip visible (with its\n * captured data) until the user dismisses it, even after the\n * underlying view no longer contains that row.\n */\n setView?(view: View): void;\n\n /**\n * Set the gridline canvas (behind WebGL, for gridlines).\n */\n setGridlineCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;\n\n /**\n * Set the chrome canvas (above WebGL, for axes/labels/legend/tooltip).\n */\n setChromeCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;\n\n /**\n * Hand the chart a pre-computed CSS-variable map produced on the\n * main thread via `snapshotThemeVars(el)`, which it can decode into\n * a full `Theme` without touching the DOM (charts always run inside\n * the renderer scope, which has no `getComputedStyle`).\n */\n setTheme?(vars: Record<string, string>): void;\n\n /**\n * Set the zoom controller for interactive zoom/pan.\n */\n setZoomController?(zc: ZoomController): void;\n\n /**\n * Wire the chart's `TooltipController` for virtual-dispatch hover /\n * click events forwarded from the host. The renderer drives\n * `dispatchHover` / `dispatchLeave` / `dispatchClick` /\n * `dispatchDblClick` from `InteractionEvent`s; the supplied\n * `HostSink` posts pin / dismiss / setCursor intents back to the\n * host so the resulting DOM mutations happen there (the renderer\n * scope has no DOM in worker mode, and uses the same channel\n * in-process for symmetry).\n */\n attachTooltip?(host: HostSink): void;\n\n /**\n * Set the column slot config (with nulls for empty slots).\n */\n setColumnSlots?(slots: (string | null)[]): void;\n\n /**\n * Set group_by and split_by config from the viewer.\n */\n setViewPivots?(groupBy: string[], splitBy: string[]): void;\n\n /**\n * Set column type schema from the view (e.g., { \"col\": \"date\" }).\n */\n setColumnTypes?(schema: Record<string, string>): void;\n\n /**\n * Set the source-column types used for `group_by` level lookups \u2014\n * sourced from `table.schema()` + `view.expression_schema()`. Used\n * by categorical-axis charts to detect numeric / date / boolean\n * group_by levels (which are not keyed in `view.schema()` because\n * they surface as `__ROW_PATH_N__` columns).\n */\n setGroupByTypes?(schema: Record<string, string>): void;\n\n /**\n * Set per-column render config (the second argument to `plugin.restore`).\n * Key is the aggregate base name; value is an open object whose\n * `chart_type` / `stack` fields are consumed by the Y-bar glyph router.\n */\n setColumnsConfig?(cfg: Record<string, any>): void;\n\n /**\n * Set the plugin's default glyph type. Used by the Y-series chart\n * family (Y Bar / Y Line / Y Scatter / Y Area): each tag is the same\n * `BarChart` impl with a different starting `chart_type` applied to\n * columns that lack an explicit entry in `columns_config`.\n */\n setDefaultChartType?(chartType: string): void;\n\n /**\n * Set the faceting config: one small-multiple sub-plot per\n * `split_by` group, optional shared axes, coordinated tooltip, and\n * zoom routing mode. Seeded from `DEFAULT_FACET_CONFIG` at init;\n * `plugin_config.facet_mode` / `facet_zoom_mode` override the\n * matching fields via `AbstractChart.setPluginConfig`.\n */\n setFacetConfig?(cfg: FacetConfig): void;\n\n /**\n * Set the plugin-scoped global configuration \u2014 the values backing\n * `plugin_config_schema` / `plugin_config` in `restore`. Replaces\n * the previous module-level constants (`LINE_WIDTH_PX`,\n * `POINT_SIZE_PX`, `BAND_INNER_FRAC`, `BAR_INNER_PAD`,\n * `WICK_WIDTH_PX`, `OHLC_LINE_WIDTH_PX`, `AUTO_ALT_Y_AXIS`) plus\n * the faceted/series zoom-mode semantics described in\n * {@link PluginConfig}.\n */\n setPluginConfig?(cfg: PluginConfig): void;\n\n /**\n * Drop any cached theme values so the next render re-reads CSS\n * variables. Driven from `plugin.restyle()`.\n */\n invalidateTheme?(): void;\n\n /**\n * Clear the `domain_mode: \"expand\"` accumulator state so the next\n * data load starts from the current data extent. Driven from\n * `resetAllZooms` (the user clicked \"Reset Zoom\"). View-config\n * mutations route through `AbstractChart`'s `setColumnSlots` /\n * `setViewPivots` / `setColumnTypes` setters, which call the same\n * hook internally.\n */\n resetExpandedDomain?(): void;\n\n /**\n * Silently clear any active selection state (pinned tooltip) WITHOUT\n * emitting selection events. Driven from the host's `deselect`\n * message \u2014 its global filter bar removed a clause this chart's\n * selection contributed, so an unselect emit would double-mutate the\n * host's filter set.\n */\n deselect?(): void;\n\n destroy(): void;\n}\n\nexport interface FacetConfig {\n /**\n * \"grid\" = small multiples (default); \"overlay\" = legacy single-plot.\n */\n facet_mode: \"grid\" | \"overlay\";\n\n /**\n * Share one bottom X axis across all columns of facets.\n */\n shared_x_axis: boolean;\n\n /**\n * Share one left Y axis across all rows of facets.\n */\n shared_y_axis: boolean;\n\n /**\n * Paint a tooltip in every facet (otherwise only the source facet).\n */\n coordinated_tooltip: boolean;\n\n /**\n * \"shared\" = one viewport for all facets; \"independent\" = per-facet.\n */\n zoom_mode: \"shared\" | \"independent\";\n\n /**\n * Pixel gap between adjacent facet cells in grid mode.\n */\n facet_padding: number;\n}\n\nexport const DEFAULT_FACET_CONFIG: FacetConfig = {\n facet_mode: \"grid\",\n shared_x_axis: true,\n shared_y_axis: true,\n coordinated_tooltip: false,\n zoom_mode: \"shared\",\n facet_padding: 6,\n};\n\n/**\n * Plugin-scoped global configuration \u2014 the user-facing settings backing\n * `plugin_config_schema()` / the `plugin_config` slot in `restore`.\n *\n * Each chart type's `plugin_config_schema` returns only the fields that\n * are applicable for that chart (see `applicable_plugin_fields` on\n * `ChartTypeConfig`); inapplicable fields are hidden in the UI. The\n * chart impl receives the full struct on `setPluginConfig` and reads\n * only the fields its render / build pipeline cares about.\n *\n * Some fields overlap with {@link FacetConfig} (`facet_mode`,\n * `facet_zoom_mode`); the base `AbstractChart.setPluginConfig` syncs\n * those onto `_facetConfig` so deep render code keeps reading the\n * single facet struct it already does. `series_zoom_mode` toggles the\n * categorical-Y chart base's `_autoFitValue` flag.\n */\nexport interface PluginConfig {\n /**\n * Auto-detect Y dual-axis splits when aggregate magnitudes differ\n * by more than `DUAL_Y_RATIO_THRESHOLD`\u00D7. Series charts only.\n * Replaces the `AUTO_ALT_Y_AXIS` compile-time toggle.\n */\n auto_alt_y_axis: boolean;\n\n /**\n * Faceting strategy when `split_by` is non-empty.\n *\n * - `\"grid\"` \u2014 one small-multiple sub-plot per split group.\n * - `\"overlay\"` \u2014 a single plot: cartesian charts differentiate\n * split groups by color; the categorical band pipeline (series\n * charts) stacks splits within each aggregate's band slot.\n * Synced into `_facetConfig.facet_mode`.\n *\n * The default differs by family via\n * `ChartTypeConfig.plugin_field_defaults`: cartesian / density /\n * map chart types default to `\"grid\"`, the series / financial\n * band-pipeline types to `\"overlay\"` (their historical split\n * rendering). Series charts REBUILD on a mode change \u2014 grid mode\n * keys the stack ladder per split (`facetSplits` in\n * `buildSeriesPipeline`) so each facet grows from its own\n * baseline.\n */\n facet_mode: \"grid\" | \"overlay\";\n\n /**\n * Faceted-cartesian zoom routing. `\"shared\"` \u2014 one viewport across\n * all facets; `\"independent\"` \u2014 wheel/pan routes to the facet under\n * the cursor with its own viewport. Synced into\n * `_facetConfig.zoom_mode`.\n */\n facet_zoom_mode: \"shared\" | \"independent\";\n\n /**\n * Series-chart value-axis behavior on zoom.\n *\n * - `\"dynamic\"` \u2014 value axis refits to the visible categorical\n * slice (current default; `CategoricalYChart._autoFitValue` =\n * true).\n * - `\"fixed\"` \u2014 value axis stays pinned to the full-data extent.\n */\n series_zoom_mode: \"fixed\" | \"dynamic\";\n\n /**\n * Anchor the value axis to zero \u2014 when true, `0` is forced into\n * the rendered domain even if all data sits well above or below\n * it. Natural for bar / area glyphs (which grow from the zero\n * baseline) and surprising for line / scatter (where the\n * interesting variation often lives far from zero). Per-chart-type\n * defaults route through `ChartTypeConfig.plugin_field_defaults`:\n * `true` for Y Bar / Y Area / X Bar, `false` elsewhere.\n */\n include_zero: boolean;\n\n /**\n * Domain accumulation policy across successive `View` updates.\n *\n * - `\"fit\"` \u2014 every update recomputes the affected domains from\n * the current data extent. Can grow or shrink frame-to-frame.\n * - `\"expand\"` \u2014 the affected domains monotonically *grow*: each\n * update unions the new data extent with the previously rendered\n * extent, so once a value is in scope it stays in scope. Reset\n * by the \"Reset Zoom\" button, view-config changes (group_by /\n * split_by / column-slot / column-type), or toggling back to\n * `\"fit\"`.\n *\n * AXIS SCOPE differs by family: cartesian charts (X/Y Scatter,\n * X/Y Line, Density, Maps) apply it to BOTH axes plus the\n * color/size scales (categorical string axes opt out \u2014 slot\n * indices are frame-local); the categorical band pipeline (series\n * / financial) applies it to the VALUE axis only \u2014 Y for the\n * Y-family, X for X Bar \u2014 while the category axis always fits, so\n * a streaming numeric/datetime `group_by` axis releases departed\n * categories instead of pinning to its history.\n */\n domain_mode: \"fit\" | \"expand\";\n\n /**\n * Width of polyline glyphs in CSS pixels (multiplied by DPR at GL\n * upload). Replaces the duplicated `LINE_WIDTH_PX` constants in\n * the cartesian + series line glyphs.\n */\n line_width_px: number;\n\n /**\n * Diameter of scatter point glyphs in CSS pixels. Replaces\n * `POINT_SIZE_PX`.\n */\n point_size_px: number;\n\n /**\n * Fraction of each category band occupied by its slot(s). Replaces\n * `BAND_INNER_FRAC`. Affects buffer contents \u2014 takes effect on\n * next data load.\n */\n band_inner_frac: number;\n\n /**\n * Relative inner padding between adjacent slots within a band.\n * Replaces `BAR_INNER_PAD`. Affects buffer contents \u2014 takes effect\n * on next data load.\n */\n bar_inner_pad: number;\n\n /**\n * Candlestick wick stroke width in CSS pixels. Replaces\n * `WICK_WIDTH_PX`.\n */\n wick_width_px: number;\n\n /**\n * OHLC bar stroke width in CSS pixels. Replaces\n * `OHLC_LINE_WIDTH_PX`.\n */\n ohlc_line_width_px: number;\n\n /**\n * density splat radius in CSS pixels. Each data point is\n * rasterized as a soft disk of this radius into the accumulation\n * FBO before the gradient LUT pass resolves to a heat color.\n */\n gradient_radius_px: number;\n\n /**\n * density per-splat intensity multiplier. Controls how\n * fast the density grows when points overlap (low values produce\n * a smoother, more diffuse field; high values produce sharper\n * peaks).\n */\n gradient_intensity: number;\n\n /**\n * density clamp on the maximum accumulated heat used for\n * the gradient-LUT lookup. Lower values saturate sooner (more of\n * the LUT's hot stops show up); higher values stay cooler. In\n * every mode this controls the alpha (intensity) ramp; in\n * `density` mode it also drives the hue, and in `signed` mode it\n * scales the signed-sum-to-hue mapping.\n */\n gradient_heat_max: number;\n\n /**\n * density color-reduction mode. Controls how each pixel's\n * stack of overlapping splats is reduced to a single LUT-t / alpha\n * pair in the resolve pass.\n *\n * - `mean` (default) \u2014 hue is the density-weighted average of\n * per-point color-t. Reads as \"the typical color-column value\n * in this region.\" Uses robust (5th/95th-percentile) bounds so\n * one outlier can't compress the rest of the data toward the\n * gradient midpoint.\n * - `density` \u2014 ignore the color column even when wired; hue and\n * alpha both follow density. Reads as \"where do points cluster.\"\n * Useful when the color column is attached for tooltip lookup\n * only.\n * - `extreme` \u2014 keep the per-pixel maximum signed deviation of\n * `t - 0.5` (split into positive and negative channels, MAX-\n * blended). Reads as \"where are the outliers.\" Density still\n * drives alpha so a single-point extreme fades naturally.\n * Requires a second framebuffer; uses MRT on WebGL2 hardware\n * with `OES_draw_buffers_indexed`, two passes otherwise.\n * - `signed` \u2014 accumulate signed `t - 0.5` and let positive vs\n * negative cancel out. Reads as \"net positive vs net negative\n * in each region.\" Requires a float-capable framebuffer; on\n * `UNSIGNED_BYTE` fallback hardware degrades silently to\n * `mean` with a one-line console warning.\n */\n gradient_color_mode: \"mean\" | \"density\" | \"extreme\" | \"signed\";\n\n /**\n * Map basemap tile provider. Applies only to map plugin tags\n * (`map-scatter`, `map-line`, `map-density`). Cartesian charts\n * ignore the field. Surfaced as an enum on the settings panel so\n * users can switch light/dark/voyager without writing custom\n * tile-source code.\n */\n map_tile_provider: \"carto-positron\" | \"carto-dark-matter\" | \"carto-voyager\";\n\n /**\n * Map basemap alpha (0..1). Pre-multiplied into the tile fragment\n * shader's output so the chart's glyph layer composites over a\n * dimmer or brighter version of the basemap. `1.0` (default)\n * shows the tiles at full opacity.\n */\n map_tile_alpha: number;\n}\n\nexport const DEFAULT_PLUGIN_CONFIG: PluginConfig = {\n auto_alt_y_axis: false,\n facet_mode: \"grid\",\n facet_zoom_mode: \"shared\",\n series_zoom_mode: \"dynamic\",\n include_zero: false,\n domain_mode: \"expand\",\n line_width_px: 2.0,\n point_size_px: 8.0,\n band_inner_frac: 0.5,\n bar_inner_pad: 0.1,\n wick_width_px: 1.0,\n ohlc_line_width_px: 1.0,\n gradient_radius_px: 32.0,\n gradient_intensity: 0.6,\n gradient_heat_max: 4.0,\n gradient_color_mode: \"mean\",\n map_tile_provider: \"carto-positron\",\n map_tile_alpha: 1.0,\n};\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { InteractionEvent } from \"../transport/protocol\";\n\n/**\n * Captures wheel / pointer events on the GL canvas, normalizes coords\n * to canvas-relative CSS pixels, and emits semantic\n * {@link InteractionEvent}s to the Renderer over its transport. The\n * Renderer owns the `ZoomController`s and runs the actual hit-test +\n * apply logic \u2014 see `applyWheel` / `applyPan` in `zoom-router.ts`.\n *\n * Pointer capture is set on `pointerdown` and released on `pointerup`\n * so drags continue to deliver `pointermove` events when the cursor\n * leaves the canvas.\n */\nexport class RawEventForwarder {\n private _element: HTMLElement | null = null;\n private _emit: ((e: InteractionEvent) => void) | null = null;\n private _pointerId: number | null = null;\n\n private _onWheel: ((e: WheelEvent) => void) | null = null;\n private _onPointerDown: ((e: PointerEvent) => void) | null = null;\n private _onPointerMove: ((e: PointerEvent) => void) | null = null;\n private _onPointerUp: ((e: PointerEvent) => void) | null = null;\n private _onPointerLeave: (() => void) | null = null;\n private _onClick: ((e: MouseEvent) => void) | null = null;\n private _onDblClick: ((e: MouseEvent) => void) | null = null;\n\n attach(element: HTMLElement, emit: (e: InteractionEvent) => void): void {\n this.detach();\n this._element = element;\n this._emit = emit;\n\n this._onWheel = (e: WheelEvent) => {\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n\n // `preventDefault` is fired unconditionally so the page\n // does not scroll while the chart is hovered \u2014 the worker\n // may still no-op if the cursor is outside any facet's\n // plot rect.\n e.preventDefault();\n emit({ type: \"wheel\", mx, my, deltaY: e.deltaY });\n };\n\n this._onPointerDown = (e: PointerEvent) => {\n // Only forward primary-button pointerdowns. Right/middle clicks must\n // reach the panel's `contextmenu` handler \u2014 capturing the pointer\n // here would otherwise swallow the right-click.\n if (e.button !== 0) {\n return;\n }\n\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n element.setPointerCapture(e.pointerId);\n this._pointerId = e.pointerId;\n emit({ type: \"pointerdown\", mx, my, pointerId: e.pointerId });\n };\n\n this._onPointerMove = (e: PointerEvent) => {\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n emit({ type: \"pointermove\", mx, my });\n };\n\n this._onPointerUp = (e: PointerEvent) => {\n if (this._pointerId !== null) {\n try {\n element.releasePointerCapture(this._pointerId);\n } catch {\n // capture may have already been released\n }\n\n this._pointerId = null;\n }\n\n void e;\n emit({ type: \"pointerup\" });\n };\n\n // Pointerleave gives the renderer a single signal that the\n // cursor truly exited the canvas \u2014 used for tooltip dismissal.\n // Hover + drag both ride the `pointermove` stream above, so no\n // parallel `mousemove` channel exists.\n this._onPointerLeave = () => {\n emit({ type: \"pointerleave\" });\n };\n\n this._onClick = (e: MouseEvent) => {\n const rect = element.getBoundingClientRect();\n emit({\n type: \"click\",\n mx: e.clientX - rect.left,\n my: e.clientY - rect.top,\n });\n };\n\n this._onDblClick = (e: MouseEvent) => {\n const rect = element.getBoundingClientRect();\n emit({\n type: \"dblclick\",\n mx: e.clientX - rect.left,\n my: e.clientY - rect.top,\n });\n };\n\n element.addEventListener(\"wheel\", this._onWheel, { passive: false });\n element.addEventListener(\"pointerdown\", this._onPointerDown);\n element.addEventListener(\"pointermove\", this._onPointerMove);\n element.addEventListener(\"pointerup\", this._onPointerUp);\n element.addEventListener(\"pointerleave\", this._onPointerLeave);\n element.addEventListener(\"click\", this._onClick);\n element.addEventListener(\"dblclick\", this._onDblClick);\n }\n\n detach(): void {\n if (this._element) {\n if (this._onWheel) {\n this._element.removeEventListener(\"wheel\", this._onWheel);\n }\n\n if (this._onPointerDown) {\n this._element.removeEventListener(\n \"pointerdown\",\n this._onPointerDown,\n );\n }\n\n if (this._onPointerMove) {\n this._element.removeEventListener(\n \"pointermove\",\n this._onPointerMove,\n );\n }\n\n if (this._onPointerUp) {\n this._element.removeEventListener(\n \"pointerup\",\n this._onPointerUp,\n );\n }\n\n if (this._onPointerLeave) {\n this._element.removeEventListener(\n \"pointerleave\",\n this._onPointerLeave,\n );\n }\n\n if (this._onClick) {\n this._element.removeEventListener(\"click\", this._onClick);\n }\n\n if (this._onDblClick) {\n this._element.removeEventListener(\"dblclick\", this._onDblClick);\n }\n }\n\n this._element = null;\n this._emit = null;\n this._pointerId = null;\n this._onPointerLeave = null;\n this._onClick = null;\n this._onDblClick = null;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { ViewConfig } from \"@perspective-dev/client\";\n\n/**\n * Detail payload for the `perspective-click` CustomEvent dispatched on\n * the `<perspective-viewer>` host when the user clicks a chart glyph.\n * Shape matches the equivalent type in `@perspective-dev/viewer-datagrid`\n * so consumers can listen to either plugin uniformly.\n */\nexport interface PerspectiveClickDetail {\n /**\n * Source-view row data \u2014 keys are column names, values are scalar\n * cell values. Empty `{}` when the click hit a non-leaf aggregate\n * (e.g. a treemap branch).\n */\n row: Record<string, unknown>;\n\n /**\n * Aggregate column(s) the click targeted. Single-entry for series /\n * heatmap / tree charts; multi-entry would only appear for plugins\n * that surface multiple measures per glyph (none today).\n */\n column_names: string[];\n\n /**\n * Pre-built `viewer.restore({ filter })` patch \u2014 concatenates the\n * group_by and split_by pivot values at the click target as\n * `[<col>, \"==\", <value>]` clauses.\n */\n config: Partial<ViewConfig>;\n\n /**\n * The source panel's `slot` name in a multi-panel `<perspective-viewer>`,\n * so the host can attribute the click to the originating panel. `undefined`\n * for a lone, unslotted viewer. Mirrors `PerspectiveSelectDetail.panel` and\n * the datagrid `PerspectiveClickDetail`.\n */\n panel?: string;\n}\n\nexport { PerspectiveSelectDetail } from \"@perspective-dev/viewer/src/ts/extensions.js\";\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { ThemeSnapshot } from \"./theme\";\n\n/**\n * CSS variables (and one inherited property) the chart renderer reads.\n * Host-only: workers can't call `getComputedStyle`, so this list (and\n * `snapshotThemeVars`) doesn't need to ship in the worker bundle.\n */\nconst THEME_VARS = [\n \"--psp-charts--font-family\",\n \"font-family\",\n \"--psp--background-color\",\n \"--psp-charts--axis-ticks--color\",\n \"--psp--color\",\n \"--psp-charts--axis-lines--color\",\n \"--psp-charts--gridline--color\",\n \"--psp-charts--gradient--background\",\n \"--psp-charts--full-gradient--background\",\n \"--psp-charts--legend--color\",\n \"--psp-charts--legend-border--color\",\n \"--psp-charts--tooltip--background\",\n \"--psp-charts--tooltip--color\",\n \"--psp-charts--tooltip--border-color\",\n \"--psp-charts--area--opacity\",\n \"--psp-charts--heatmap-gap--px\",\n \"--psp-charts--sunburst-gap--px\",\n];\n\n/**\n * Capture every CSS variable the renderer cares about into a\n * structured-cloneable map. Series-palette colours are walked until the\n * first missing var.\n */\nexport function snapshotThemeVars(el: Element): ThemeSnapshot {\n const style = getComputedStyle(el);\n const out: ThemeSnapshot = {};\n for (const v of THEME_VARS) {\n const raw = style.getPropertyValue(v).trim();\n if (raw) {\n out[v] = raw;\n }\n }\n\n for (let i = 1; ; i++) {\n const key = `--psp-charts--series-${i}--color`;\n const raw = style.getPropertyValue(key).trim();\n if (!raw) {\n break;\n }\n\n out[key] = raw;\n }\n\n return out;\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { FontFaceDescriptor } from \"../transport/protocol\";\n\n/**\n * Walk every accessible `@font-face` rule in the document and collect a\n * descriptor list ready for forwarding to a Web Worker, where each\n * entry is reconstituted via `new FontFace(family, src, descriptors)`\n * and registered in the worker's own `self.fonts` set.\n *\n * Background: a `Worker` has its own `FontFaceSet` distinct from the\n * document's. Fonts loaded into `document.fonts` (by `<link>`,\n * `@font-face`, or programmatic `FontFace`) are *not* visible to the\n * worker \u2014 Canvas2D `ctx.font` lookups inside the worker fall back to\n * the platform default if the family isn't in `self.fonts`. This\n * helper bridges that gap for the in-CSS case.\n *\n * # CORS / security caveats\n *\n * 1. **Cross-origin stylesheets without permissive CORS** throw\n * `SecurityError` on `cssRules` access, and we silently skip them.\n * Their `@font-face` rules are unreachable to JS regardless of\n * where the worker would re-load them, so this is the same\n * fundamental limitation the document itself has.\n *\n * 2. **Font URLs are absolutized against the parent stylesheet's\n * `href`** before forwarding. The worker's own script URL is a\n * Blob URL produced by `WorkerPlugin`, so relative URLs in the raw\n * `src:` declaration would resolve against the Blob origin (i.e.\n * fail). Callers should treat the absolute URLs as the canonical\n * source.\n *\n * 3. **The actual font fetch issued by `face.load()` in the worker\n * is a fresh cross-origin request from the worker scope.** The\n * font server must respond with `Access-Control-Allow-Origin`\n * (e.g. `*` or the page origin) and an appropriate\n * `Access-Control-Allow-Headers` policy if any non-simple headers\n * are involved. A \"no-cors\" / opaque response is *not* usable\n * here: `FontFace.load()` rejects on opaque responses, and even\n * if it didn't, painted glyphs would taint the canvas and break\n * `getImageData`. Same-origin fonts (including `data:` URIs)\n * sidestep this entirely.\n *\n * 4. **Programmatic fonts** (e.g. `document.fonts.add(new\n * FontFace(name, source))`) are *not* captured by this walker \u2014\n * they don't appear in any stylesheet's `cssRules`. Iterating\n * `document.fonts` directly would catch them, but `FontFace`\n * instances don't expose their source URL or buffer post-\n * construction, so there's no public path to forward them. If a\n * test or app needs that, it must register the same fonts in the\n * worker explicitly.\n */\nexport function snapshotFontFaces(): FontFaceDescriptor[] {\n const out: FontFaceDescriptor[] = [];\n for (const sheet of Array.from(document.styleSheets)) {\n let rules: CSSRuleList;\n try {\n rules = sheet.cssRules;\n } catch {\n // Cross-origin stylesheet without permissive CORS \u2014 its\n // `@font-face` rules are unreachable to JS. See caveat (1).\n continue;\n }\n\n const base = sheet.href ?? document.baseURI;\n for (const rule of Array.from(rules)) {\n if (!(rule instanceof CSSFontFaceRule)) {\n continue;\n }\n\n const style = rule.style;\n const rawFamily = style.getPropertyValue(\"font-family\").trim();\n const rawSrc = style.getPropertyValue(\"src\").trim();\n if (!rawFamily || !rawSrc) {\n continue;\n }\n\n out.push({\n // CSSOM serializes multi-word family names with their\n // CSS quotes preserved (e.g. `\"Roboto Mono\"`). The\n // `FontFace` constructor *doesn't* unquote on parse \u2014\n // Chromium stores the literal input and re-quotes /\n // escapes on `face.family` getter access, yielding\n // `\"\\\"Roboto Mono\\\"\"` and a name that no `ctx.font`\n // lookup can match. Strip one layer of matching outer\n // quotes here so the worker's font set keys align\n // with how Canvas2D resolves family names.\n family: stripOuterQuotes(rawFamily),\n src: resolveSrcUrls(rawSrc, base),\n style: optional(style, \"font-style\"),\n weight: optional(style, \"font-weight\"),\n stretch: optional(style, \"font-stretch\"),\n unicodeRange: optional(style, \"unicode-range\"),\n variant: optional(style, \"font-variant\"),\n featureSettings: optional(style, \"font-feature-settings\"),\n display: optional(style, \"font-display\"),\n });\n }\n }\n\n return out;\n}\n\nfunction optional(\n style: CSSStyleDeclaration,\n prop: string,\n): string | undefined {\n const v = style.getPropertyValue(prop).trim();\n return v || undefined;\n}\n\n/**\n * Remove a single matching pair of outer `\"\u2026\"` or `'\u2026'` quotes from a\n * family name. CSSOM serializes multi-word `font-family` descriptor\n * values with their quotes preserved; `FontFace` then re-quotes on\n * serialization, producing the literal `\"\\\"Foo\\\"\"` double-quoting\n * observed in `face.family`. Stripping one layer here aligns the\n * stored family with what Canvas2D resolves at render time.\n */\nfunction stripOuterQuotes(s: string): string {\n if (s.length >= 2) {\n const first = s.charCodeAt(0);\n const last = s.charCodeAt(s.length - 1);\n if (first === last && (first === 0x22 || first === 0x27)) {\n return s.slice(1, -1);\n }\n }\n\n return s;\n}\n\n/**\n * Rewrite every `url(...)` token inside a CSS `src:` value to its\n * absolute form. Multi-source declarations (`url(...) format(...),\n * url(...) format(...)`) are handled by replacing each `url(...)`\n * chunk independently. See caveat (2).\n */\nfunction resolveSrcUrls(src: string, base: string): string {\n return src.replace(\n /url\\(\\s*(['\"]?)([^'\")]+)\\1\\s*\\)/g,\n (match, _quote, url) => {\n try {\n return `url(${new URL(url, base).href})`;\n } catch {\n return match;\n }\n },\n );\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { CssBounds, HostSink } from \"./tooltip-controller\";\n\n/**\n * Host-side `HostSink` that materializes pinned tooltips as a `<div>`\n * next to the GL canvas, and applies cursor changes to the canvas's\n * own `style.cursor`. Host-only \u2014 depends on `document` /\n * `getComputedStyle`.\n */\nexport class DomHostSink implements HostSink {\n private _glCanvas: HTMLCanvasElement;\n private _parent: HTMLElement;\n private _div: HTMLDivElement | null = null;\n\n constructor(glCanvas: HTMLCanvasElement, parent: HTMLElement) {\n this._glCanvas = glCanvas;\n this._parent = parent;\n }\n\n pin(\n lines: string[],\n pos: { px: number; py: number },\n bounds: CssBounds,\n ): void {\n this.dismiss();\n const div = document.createElement(\"div\");\n\n div.className = \"webgl-tooltip\";\n div.style.maxHeight = `${Math.round(bounds.cssHeight * 0.6)}px`;\n div.textContent = lines.join(\"\\n\");\n\n if (getComputedStyle(this._parent).position === \"static\") {\n this._parent.style.position = \"relative\";\n }\n\n div.style.left = \"-9999px\";\n div.style.top = \"0px\";\n this._parent.appendChild(div);\n this._div = div;\n const divW = div.getBoundingClientRect().width;\n const divH = div.getBoundingClientRect().height;\n let tx = pos.px + 12;\n let ty = pos.py - divH - 8;\n if (tx + divW > bounds.cssWidth) {\n tx = pos.px - divW - 12;\n }\n\n if (tx < 0) {\n tx = 4;\n }\n\n if (ty < 0) {\n ty = pos.py + 12;\n }\n\n if (ty + divH > bounds.cssHeight) {\n ty = bounds.cssHeight - divH - 4;\n }\n\n div.style.left = `${tx}px`;\n div.style.top = `${ty}px`;\n }\n\n dismiss(): void {\n if (this._div) {\n this._div.remove();\n this._div = null;\n }\n }\n\n setCursor(cursor: string): void {\n this._glCanvas.style.cursor = cursor;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * Renderer mode. `\"worker\"` runs the chart code in a Web Worker (off\n * the main thread, gets parallelism but pays a postMessage hop on\n * every interaction). `\"inprocess\"` dynamic-imports the same worker\n * module on the main thread so the bundle stays single-copy without\n * the worker boundary. The two paths share a `MessageChannel`-shaped\n * control protocol \u2014 only the handle around it differs.\n */\nexport const RUNTIME_MODE: \"worker\" | \"inprocess\" = \"worker\";\n\n/**\n * Build-time toggle between the two GL-canvas display strategies.\n *\n * - `\"direct\"` \u2014 host transfers `.webgl-canvas` to the renderer via\n * `transferControlToOffscreen`. The renderer's GL context renders\n * straight into the visible drawing buffer.\n *\n * - `\"blit\"` \u2014 host keeps the visible canvas main-thread with a 2D\n * context. The renderer creates its own internal `OffscreenCanvas`\n * for GL rendering and emits each completed frame as an\n * `ImageBitmap` over the control channel; the host blits the bitmap\n * into the visible canvas via `drawImage`.\n */\nexport const RENDER_BLIT_MODE: \"direct\" | \"blit\" = \"blit\";\n\n/**\n * Number of shared WebGL contexts in pooled blit mode.\n *\n * The browser caps live contexts per agent (~16 in Chromium) and\n * force-loses the oldest past that cap, so a page with more charts than\n * the cap cannot give each its own context. When `> 0` *and*\n * `RENDER_BLIT_MODE === \"blit\"`, every chart borrows one of this many\n * shared contexts (round-robin, sticky for the chart's lifetime) instead\n * of allocating its own \u2014 decoupling live-context count from chart\n * count. N charts render through K = this many contexts; the scheduler\n * serializes renders that land on the same context.\n *\n * `0` disables pooling (every chart gets its own context \u2014 the original\n * behavior). Pooling never applies to `\"direct\"` mode, which renders\n * into the host's transferred visible canvas and is permanently 1:1 with\n * a context; keep pages that need more than ~16 simultaneous charts on\n * `\"blit\"`.\n */\nexport const RENDER_CONTEXT_POOL_SIZE: number = 4;\n\n/**\n * Strict-mode validation for `BufferPool.upload`.\n */\nexport const BUFFER_POOL_STRICT: boolean = false;\n", "var jr=Object.defineProperty;var Vl=(e,t,n)=>t in e?jr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var Hl=(e,t)=>{for(var n in t)jr(e,n,{get:t[n],enumerable:!0})};var c=(e,t,n)=>Vl(e,typeof t!=\"symbol\"?t+\"\":t,n);var In,Li=G(()=>{In=\"attribute vec2 a_start;attribute vec2 a_end;attribute float a_color_start;attribute float a_color_end;attribute float a_corner;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform vec2 u_color_range;uniform sampler2D u_gradient_lut;varying float v_edge_dist;varying vec3 v_color;float A(float B,float C,float D){if(D<=C){return 0.5;}else if(C<0.&&D>0.){float E=max(-C,D);return clamp(0.5+0.5*(B/E),0.,1.);}return clamp((B-C)/(D-C),0.,1.);}void main(){float C=u_color_range.x;float D=u_color_range.y;float F=0.5*(a_color_start+a_color_end);float G=A(F,C,D);v_color=texture2D(u_gradient_lut,vec2(G,0.5)).rgb;vec4 H=u_projection*vec4(a_start,0.,1.);vec4 I=u_projection*vec4(a_end,0.,1.);vec2 J=H.xy*u_resolution*0.5;vec2 K=I.xy*u_resolution*0.5;vec2 L=K-J;float M=length(L);L=M>0.001?L/M:vec2(1.,0.);vec2 N=vec2(-L.y,L.x);float O=step(1.5,a_corner);float P=1.-mod(a_corner,2.)*2.;vec4 Q=mix(H,I,O);float R=(u_line_width+1.5)*0.5;vec2 S=(N*P*R)/(u_resolution*0.5);gl_Position=Q+vec4(S,0.,0.);v_edge_dist=P;}\"});var Dn,Ti=G(()=>{Dn=\"precision highp float;uniform float u_line_width;varying float v_edge_dist;varying vec3 v_color;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(v_color,C);}\"});var Bn,Ri=G(()=>{Bn=\"attribute vec2 a_position;attribute float a_color_value;attribute float a_size_value;uniform mat4 u_projection;uniform float u_point_size;uniform vec2 u_color_range;uniform vec2 u_size_range;uniform vec2 u_point_size_range;varying float v_color_t;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);float A=u_size_range.y-u_size_range.x;if(A>0.){float B=clamp((a_size_value-u_size_range.x)/A,0.,1.);gl_PointSize=mix(u_point_size_range.x,u_point_size_range.y,B);}else{gl_PointSize=u_point_size;}v_point_size=gl_PointSize;float C=u_color_range.x;float D=u_color_range.y;if(D<=C){v_color_t=0.5;}else if(C<0.&&D>0.){float E=max(-C,D);v_color_t=clamp(0.5+0.5*(a_color_value/E),0.,1.);}else{v_color_t=clamp((a_color_value-C)/(D-C),0.,1.);}}\"});var Pn,wi=G(()=>{Pn=\"precision highp float;varying float v_color_t;varying float v_point_size;uniform sampler2D u_gradient_lut;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5){discard;}float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);vec4 E=texture2D(u_gradient_lut,vec2(clamp(v_color_t,0.,1.),0.5));gl_FragColor=vec4(E.rgb,E.a*D);}\"});var xt,Mi=G(()=>{xt=\"attribute vec2 a_corner;attribute vec2 a_position;attribute float a_color_value;uniform vec2 u_radius_ndc;uniform mat4 u_projection;uniform vec2 u_color_range;varying vec2 v_uv;varying float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}\"});var $n,Fi=G(()=>{$n=\"precision highp float;uniform float u_intensity;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);float B=max(0.,1.-A);B=B*B*u_intensity;if(B<=0.){discard;}gl_FragColor=vec4(B,B*v_color_t,0.,0.);}\"});var jn,Si=G(()=>{jn=\"precision highp float;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);if(A>=1.){discard;}float B=(v_color_t-0.5)*2.;gl_FragColor=vec4(max(0.,B),max(0.,-B),0.,0.);}\"});var qr,Zr=G(()=>{qr=`#version 300 es\nin vec2 a_corner;in vec2 a_position;in float a_color_value;uniform mat4 u_projection;uniform vec2 u_radius_ndc;uniform vec2 u_color_range;out vec2 v_uv;out float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}`});var Jr,Kr=G(()=>{Jr=`#version 300 es\nprecision highp float;uniform float u_intensity;in vec2 v_uv;in float v_color_t;layout(location=0)out vec4 A;layout(location=1)out vec4 B;void main(){float C=length(v_uv);float D=max(0.0f,1.0f-C);D=D*D*u_intensity;if(D<=0.0f){discard;}A=vec4(D,D*v_color_t,0.0f,0.0f);float E=(v_color_t-0.5f)*2.0f;B=vec4(max(0.0f,E),max(0.0f,-E),0.0f,0.0f);}`});var Zn,Ii=G(()=>{Zn=\"attribute vec2 a_corner;varying vec2 v_uv;void main(){v_uv=a_corner*0.5+0.5;gl_Position=vec4(a_corner,0.,1.);}\"});var qn,Di=G(()=>{qn=\"precision highp float;uniform sampler2D u_heat;uniform sampler2D u_extreme;uniform sampler2D u_gradient_lut;uniform float u_heat_max;uniform int u_color_mode;varying vec2 v_uv;void main(){vec4 A=texture2D(u_heat,v_uv);float B=A.r;float C=A.g;if(B<=0.){discard;}float D;float E;float F=clamp(B/max(u_heat_max,1e-4),0.,1.);if(u_color_mode==0){D=pow(F,0.6);E=clamp(B,0.,1.);}else if(u_color_mode==2){vec4 G=texture2D(u_extreme,v_uv);float H=G.r;float I=G.g;float J=max(H,I);if(J<=0.){D=0.5;}else if(H>=I){D=clamp(0.5+H*0.5,0.5,1.);}else{D=clamp(0.5-I*0.5,0.,0.5);}E=F;}else if(u_color_mode==3){float K=C-0.5*B;float L=clamp(abs(K)/max(u_heat_max,1e-4),0.,1.);float M=K>=0.?1.:-1.;D=clamp(0.5+0.5*M*L,0.,1.);E=L;}else{D=clamp(C/B,0.,1.);E=F;}vec4 N=texture2D(u_gradient_lut,vec2(D,0.5));gl_FragColor=vec4(N.rgb,N.a*E);}\"});var Kn,Bi=G(()=>{Kn=\"attribute vec2 a_corner;uniform mat4 u_projection;uniform vec2 u_extent_min;uniform vec2 u_extent_max;uniform vec2 u_uv_min;uniform vec2 u_uv_max;varying vec2 v_uv;void main(){vec2 A=mix(u_extent_min,u_extent_max,a_corner);vec2 B=mix(u_uv_min,u_uv_max,vec2(a_corner.x,1.-a_corner.y));v_uv=B;gl_Position=u_projection*vec4(A,0.,1.);}\"});var Jn,Pi=G(()=>{Jn=\"precision highp float;varying vec2 v_uv;uniform sampler2D u_tile;uniform float u_alpha;void main(){vec4 A=texture2D(u_tile,v_uv);gl_FragColor=vec4(A.rgb,A.a*u_alpha);}\"});function _u(e,t){if(t.width<=0||t.height<=0)return e;let n=e.xMax-e.xMin,o=e.yMax-e.yMin;if(n<=0||o<=0)return e;let i=t.width/t.height;if(n/o<i){let s=(e.xMin+e.xMax)/2,a=o*i/2;return{xMin:s-a,xMax:s+a,yMin:e.yMin,yMax:e.yMax}}else{let s=(e.yMin+e.yMax)/2,a=n/i/2;return{xMin:e.xMin,xMax:e.xMax,yMin:s-a,yMax:s+a}}}var yt,eo=G(()=>{\"use strict\";yt=class{constructor(){c(this,\"ce\",1);c(this,\"de\",1);c(this,\"Se\",0);c(this,\"Ie\",0);c(this,\"Tt\",0);c(this,\"Rt\",1);c(this,\"wt\",0);c(this,\"Mt\",1);c(this,\"Xe\",null);c(this,\"Li\",!1);c(this,\"Go\",!1);c(this,\"Wo\",!1);c(this,\"Ft\",null);c(this,\"St\",null);c(this,\"Xn\",null);c(this,\"ko\",!1);c(this,\"No\",0);c(this,\"Uo\",0);c(this,\"$n\",null);c(this,\"jn\",null);c(this,\"Zn\",null);c(this,\"qn\",null)}get lockedAxis(){return this.Xe}get scaleX(){return this.ce}get scaleY(){return this.de}set scaleX(t){this.ce=t}set scaleY(t){this.de=t}get normTranslateX(){return this.Se}get normTranslateY(){return this.Ie}set normTranslateX(t){this.Se=t}set normTranslateY(t){this.Ie=t}get baseXRange(){return this.Rt-this.Tt}get baseYRange(){return this.Mt-this.wt}setBaseDomain(t,n,o,i){let r=n-t;if(this.isXDefault()||!this.Go)this.Tt=t,this.Rt=n;else{let a=this.Rt-this.Tt,l=(this.Tt+this.Rt)/2+this.Se*a;this.Tt=t,this.Rt=n,this.Se=r>0?(l-(t+n)/2)/r:0}let s=i-o;if(this.isYDefault()||!this.Wo)this.wt=o,this.Mt=i;else{let a=this.Mt-this.wt,l=(this.wt+this.Mt)/2+this.Ie*a;this.wt=o,this.Mt=i,this.Ie=s>0?(l-(o+i)/2)/s:0}}pinAxis(t){t===\"x\"?this.Go=!0:this.Wo=!0}unpinAxis(t){t===\"x\"?this.Go=!1:this.Wo=!1}configure(t){this.Xe=t.lockAxis??null,this.Li=t.lockAspect??!1,this.Xe===\"x\"?(this.ce=1,this.Se=0):this.Xe===\"y\"&&(this.de=1,this.Ie=0)}isXDefault(){return this.ce===1&&this.Se===0}isYDefault(){return this.de===1&&this.Ie===0}isDefault(){return this.isXDefault()&&this.isYDefault()}getVisibleDomain(){let t=this.Rt-this.Tt,n=this.Mt-this.wt,o=t/this.ce,i=n/this.de,r=(this.Tt+this.Rt)/2+this.Se*t,s=(this.wt+this.Mt)/2+this.Ie*n,a={xMin:r-o/2,xMax:r+o/2,yMin:s-i/2,yMax:s+i/2};return this.Li&&this.St?_u(a,this.St.e):a}attach(t,n,o){this.detach(),this.Ft=t,this.St=n,this.Xn=o,this.$n=i=>{i.preventDefault();let r=t.getBoundingClientRect(),s=i.clientX-r.left,a=i.clientY-r.top,l=this.St.e;if(s<l.x||s>l.x+l.width||a<l.y||a>l.y+l.height)return;let u=(s-l.x)/l.width,m=(a-l.y)/l.height,f=this.ce,p=this.de,d=Math.pow(1.1,-i.deltaY/100);this.Xe!==\"x\"&&(this.ce=Math.max(1,Math.min(1e5,this.ce*d))),this.Xe!==\"y\"&&(this.de=Math.max(1,Math.min(1e5,this.de*d))),this.Xe!==\"x\"&&f!==this.ce&&(this.Se+=(u-.5)*(1/f-1/this.ce)),this.Xe!==\"y\"&&p!==this.de&&(this.Ie+=(.5-m)*(1/p-1/this.de)),this.Xn()},this.jn=i=>{if(i.button!==0)return;let r=t.getBoundingClientRect(),s=i.clientX-r.left,a=i.clientY-r.top,l=this.St.e;s>=l.x&&s<=l.x+l.width&&a>=l.y&&a<=l.y+l.height&&(this.ko=!0,this.No=i.clientX,this.Uo=i.clientY,t.setPointerCapture(i.pointerId))},this.Zn=i=>{if(!this.ko)return;let r=i.clientX-this.No,s=i.clientY-this.Uo;this.No=i.clientX,this.Uo=i.clientY;let a=this.St.e;this.Xe!==\"x\"&&a.width>0&&(this.Se-=r/(a.width*this.ce)),this.Xe!==\"y\"&&a.height>0&&(this.Ie+=s/(a.height*this.de)),this.Xn()},this.qn=()=>{this.ko=!1},t.addEventListener(\"wheel\",this.$n,{passive:!1}),t.addEventListener(\"pointerdown\",this.jn),t.addEventListener(\"pointermove\",this.Zn),t.addEventListener(\"pointerup\",this.qn)}updateLayout(t){this.St=t}detach(){this.Ft&&(this.$n&&this.Ft.removeEventListener(\"wheel\",this.$n),this.jn&&this.Ft.removeEventListener(\"pointerdown\",this.jn),this.Zn&&this.Ft.removeEventListener(\"pointermove\",this.Zn),this.qn&&this.Ft.removeEventListener(\"pointerup\",this.qn)),this.Ft=null,this.Xn=null}reset(){this.ce=1,this.de=1,this.Se=0,this.Ie=0}serialize(){return{scaleX:this.ce,scaleY:this.de,normTranslateX:this.Se,normTranslateY:this.Ie}}restore(t){this.ce=t.scaleX,this.de=t.scaleY,this.Se=t.normTranslateX,this.Ie=t.normTranslateY}}});function is(e){return e&&!(\"format\"in e)?e:void 0}function Gi(e,t){let n=t??vu[e]??{};return new Intl.NumberFormat(navigator.languages,n)}function Wi(e){if(!e||!(\"format\"in e)){let n=is(e),o={timeZone:n?.timeZone??void 0,dateStyle:n?.dateStyle===\"disabled\"?void 0:n?.dateStyle??os.dateStyle,timeStyle:n?.timeStyle===\"disabled\"?void 0:n?.timeStyle??os.timeStyle};return new Intl.DateTimeFormat(navigator.languages,o)}let t={timeZone:e.timeZone??void 0,hour12:e.hour12??!0,fractionalSecondDigits:e.fractionalSecondDigits};return e.year!==\"disabled\"&&(t.year=e.year??\"2-digit\"),e.month!==\"disabled\"&&(t.month=e.month??\"numeric\"),e.day!==\"disabled\"&&(t.day=e.day??\"numeric\"),e.weekday&&e.weekday!==\"disabled\"&&(t.weekday=e.weekday),e.hour!==\"disabled\"&&(t.hour=e.hour??\"numeric\"),e.minute!==\"disabled\"&&(t.minute=e.minute??\"numeric\"),e.second!==\"disabled\"&&(t.second=e.second??\"numeric\"),new Intl.DateTimeFormat(navigator.languages,t)}function rs(e){let t=is(e),n={timeZone:\"utc\",dateStyle:t?.dateStyle===\"disabled\"?void 0:t?.dateStyle??Au.dateStyle};return new Intl.DateTimeFormat(navigator.languages,n)}function ki(e){return e.split(\"|\").at(-1)??e}var vu,os,Au,ss=G(()=>{\"use strict\";vu={float:{style:\"decimal\",minimumFractionDigits:2,maximumFractionDigits:2}},os={dateStyle:\"short\",timeStyle:\"medium\"},Au={dateStyle:\"short\"}});var no,as=G(()=>{\"use strict\";no=class{constructor(t,n=128){c(this,\"$t\");c(this,\"d\",new Map);c(this,\"Ae\",new Map);c(this,\"Ti\");this.$t=t,this.Ti=n}async fetchRow(t){if(!this.$t)throw new Error(\"LazyRowFetcher disposed\");let n=this.d.get(t);if(n)return this.d.delete(t),this.d.set(t,n),n;let o=this.Ae.get(t);if(o)return o;let i=this.tr(t);this.Ae.set(t,i);try{let r=await i;if(!this.$t)return r;if(this.d.set(t,r),this.d.size>this.Ti){let s=this.d.keys().next().value;s!==void 0&&this.d.delete(s)}return r}finally{this.Ae.delete(t)}}async tr(t){let n=this.$t;if(!n)throw new Error(\"LazyRowFetcher disposed\");let o=new Map;return await n.with_typed_arrays({start_row:t,end_row:t+1,float32:!0},(i,r,s,a)=>{for(let l=0;l<i.length;l++){let u=i[l];if(u.startsWith(\"__\"))continue;let m=r[l],f=s[l],p=a[l];(f?!(f[0]>>0&1):!1)?o.set(u,null):p?o.set(u,p[m[0]]):o.set(u,m[0])}}),o}dispose(){this.$t=null,this.d.clear(),this.Ae.clear()}get isDisposed(){return this.$t===null}}});function ls(e,t){let n=Math.floor(Math.log10(e)),o=e/Math.pow(10,n),i;return t?o<1.5?i=1:o<3?i=2:o<7?i=5:i=10:o<=1?i=1:o<=2?i=2:o<=5?i=5:i=10,i*Math.pow(10,n)}function ie(e,t,n){n<1&&(n=1);let o=ls(t-e,!1),i=ls(o/n,!0),r=Math.ceil(e/i)*i,s=Math.floor(t/i)*i,a=[];for(let l=r;l<=s+i*.001;l+=i)a.push(l);return a}function me(e){if(!Number.isFinite(e))return\"-\";let t=Math.abs(e);return t===0?\"0\":t>=1e9?(e/1e9).toFixed(1)+\"B\":t>=1e6?(e/1e6).toFixed(1)+\"M\":t>=1e3?(e/1e3).toFixed(1)+\"K\":Number.isInteger(e)?e.toString():t>=1?e.toFixed(1):e.toFixed(2)}function ye(e,t){let n=new Date(e);return isNaN(n.getTime())?me(e):t!==void 0&&t>0?t>=864e5*28?n.toLocaleDateString(void 0,{year:\"numeric\",month:\"short\"}):t>=864e5?n.toLocaleDateString(void 0,{month:\"short\",day:\"numeric\"}):t>=36e5?n.toLocaleString(void 0,{month:\"short\",day:\"numeric\",hour:\"numeric\"}):t>=6e4?n.toLocaleTimeString(void 0,{hour:\"numeric\",minute:\"2-digit\"}):n.toLocaleTimeString(void 0,{hour:\"numeric\",minute:\"2-digit\",second:\"2-digit\"}):n.toLocaleDateString(void 0,{year:\"numeric\",month:\"short\",day:\"numeric\"})}var Ae=G(()=>{\"use strict\"});var us,ms,fs=G(()=>{\"use strict\";us={facet_mode:\"grid\",shared_x_axis:!0,shared_y_axis:!0,coordinated_tooltip:!1,zoom_mode:\"shared\",facet_padding:6},ms={auto_alt_y_axis:!1,facet_mode:\"grid\",facet_zoom_mode:\"shared\",series_zoom_mode:\"dynamic\",include_zero:!1,domain_mode:\"expand\",line_width_px:2,point_size_px:8,band_inner_frac:.5,bar_inner_pad:.1,wick_width_px:1,ohlc_line_width_px:1,gradient_radius_px:32,gradient_intensity:.6,gradient_heat_max:4,gradient_color_mode:\"mean\",map_tile_provider:\"carto-positron\",map_tile_alpha:1}});function Pe(e,t,n,o,i,r,s={}){if(!e)return;let a=e.getContext(\"2d\");if(!a)return;a.save(),a.setTransform(1,0,0,1,0,0),a.scale(r,r),a.font=`11px ${i.fontFamily}`;let l=16,u=8,m=0;for(let h of n){let g=a.measureText(h).width;g>m&&(m=g)}let f=m+u*2,p=n.length*l+u*2-4,d=t.px+12,b=t.py-p-8;d+f>o.cssWidth&&(d=t.px-f-12),b<0&&(b=t.py+12),b+p>o.cssHeight&&(b=o.cssHeight-p-4);let x=n.length>0;if(s.crosshair&&(a.strokeStyle=i.It,a.globalAlpha=.3,a.lineWidth=1,a.setLineDash([4,4]),a.beginPath(),a.moveTo(t.px,o.e.y),a.lineTo(t.px,o.e.y+o.e.height),a.moveTo(o.e.x,t.py),a.lineTo(o.e.x+o.e.width,t.py),a.stroke(),a.setLineDash([]),a.globalAlpha=1),s.highlightRadius&&s.highlightRadius>0&&(a.strokeStyle=i.It,a.globalAlpha=.8,a.lineWidth=2,a.beginPath(),a.arc(t.px,t.py,s.highlightRadius,0,Math.PI*2),a.stroke(),a.globalAlpha=1),x){a.fillStyle=i.Kn,a.strokeStyle=i.Ri,a.lineWidth=1,a.beginPath(),a.roundRect(d,b,f,p,4),a.fill(),a.stroke(),a.fillStyle=i.wi,a.textAlign=\"left\",a.textBaseline=\"top\";for(let h=0;h<n.length;h++)a.fillText(n[h],d+u,b+u+h*l)}a.restore()}var oo,Ct=G(()=>{\"use strict\";oo=class{constructor(){c(this,\"We\",null);c(this,\"jt\",0);c(this,\"Zt\",null);c(this,\"ln\",null);c(this,\"gt\",!1)}get isPinned(){return this.gt}setHost(t){this.gt&&(this.ln?.dismiss(),this.gt=!1),this.ln=t}setCursor(t){this.ln?.setCursor(t)}attach(t){this.detach(),this.We=t}detach(){this.jt&&(cancelAnimationFrame(this.jt),this.jt=0),this.Zt!==null&&(clearTimeout(this.Zt),this.Zt=null),this.We=null}dispatchHover(t,n){if(this.gt||!this.We||this.jt||this.Zt!==null)return;let o=()=>{this.jt=0,this.Zt=null,this.We?.onHover(t,n)};typeof requestAnimationFrame==\"function\"?this.jt=requestAnimationFrame(o):this.Zt=setTimeout(o,16)}dispatchLeave(){this.gt||!this.We||this.We.onLeave()}dispatchClick(t,n){if(this.We&&!this.We.onClickPre?.(t,n)){if(this.gt){let o=this.We;this.dismiss(),o.onUnpin?.();return}this.We.onPin?.(t,n)}}dispatchDblClick(t,n){this.We?.onDblClick?.(t,n)}pin(t,n,o){t.length!==0&&(this.ln?.pin(t,n,o),this.gt=!0)}dismiss(){this.ln?.dismiss(),this.gt=!1}}});function io(e){let t=e.trim();if(t.startsWith(\"#\")){let o=t.slice(1);return o.length===3&&(o=o[0]+o[0]+o[1]+o[1]+o[2]+o[2]),[parseInt(o.slice(0,2),16)/255,parseInt(o.slice(2,4),16)/255,parseInt(o.slice(4,6),16)/255]}let n=t.match(/rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)/);return n?[+n[1]/255,+n[2]/255,+n[3]/255]:[.5,.5,.5]}var Ni=G(()=>{\"use strict\"});function cs(e){if(!e)return it.slice();let t=e.trim();if(!t)return it.slice();let n=t.indexOf(\"(\");if(n<0||!/^linear-gradient\\s*\\(/i.test(t))return it.slice();let o=t.lastIndexOf(\")\");if(o<=n)return it.slice();let i=t.substring(n+1,o),r=[],s=0,a=0;for(let p=0;p<i.length;p++){let d=i[p];d===\"(\"?s++:d===\")\"?s--:d===\",\"&&s===0&&(r.push(i.substring(a,p)),a=p+1)}r.push(i.substring(a));let l=[],u=0;if(r.length>0){let p=r[0].trim().toLowerCase();(p.startsWith(\"to \")||/^[-\\d.]+(deg|rad|grad|turn)/.test(p))&&(u=1)}for(let p=u;p<r.length;p++){let d=r[p].trim();if(!d)continue;let b=d.match(/\\s([\\-\\d.]+)%\\s*$/),x=b?d.substring(0,b.index).trim():d,h=b?parseFloat(b[1])/100:null;try{let g=io(x);l.push({color:g,offset:h})}catch{}}if(l.length===0)return it.slice();if(l.length===1){let[p,d,b]=l[0].color;return[{offset:0,color:[p,d,b,1]},{offset:1,color:[p,d,b,1]}]}l[0].offset===null&&(l[0].offset=0),l[l.length-1].offset===null&&(l[l.length-1].offset=1);for(let p=1;p<l.length-1;p++){if(l[p].offset!==null)continue;let d=p+1;for(;d<l.length&&l[d].offset===null;)d++;let b=l[p-1].offset,x=l[d].offset,h=d-(p-1);for(let g=p;g<d;g++)l[g].offset=b+(g-(p-1))/h*(x-b);p=d-1}let m=0;return l.map(p=>{let d=Math.max(m,Math.min(1,p.offset));return m=d,{offset:d,color:[p.color[0],p.color[1],p.color[2],1]}})}function Le(e,t){if(e.length===0)return[0,0,0,1];if(t<=e[0].offset)return e[0].color.slice();let n=e[e.length-1];if(t>=n.offset)return n.color.slice();let o=0,i=e.length-1;for(;i-o>1;){let u=o+i>>1;e[u].offset<=t?o=u:i=u}let r=e[o],s=e[i],a=s.offset-r.offset,l=a>0?(t-r.offset)/a:0;return[r.color[0]+(s.color[0]-r.color[0])*l,r.color[1]+(s.color[1]-r.color[1])*l,r.color[2]+(s.color[2]-r.color[2])*l,r.color[3]+(s.color[3]-r.color[3])*l]}function rt(e,t,n){if(!isFinite(e)||t===n)return .5;let o;if(t>=0?o=n:n<=0?o=-t:o=Math.max(-t,n),o<=0)return .5;let i=.5+.5*(e/o);return i<0?0:i>1?1:i}function ds(e){if(e.length===0)return it.slice();if(e.length===1){let[n,o,i]=e[0];return[{offset:0,color:[n,o,i,1]},{offset:1,color:[n,o,i,1]}]}let t=e.length-1;return e.map(([n,o,i],r)=>({offset:r/t,color:[n,o,i,1]}))}function ps(e,t=256){let n=new Uint8Array(t*4);for(let o=0;o<t;o++){let i=t===1?0:o/(t-1),r=Le(e,i);n[o*4]=Math.round(r[0]*255),n[o*4+1]=Math.round(r[1]*255),n[o*4+2]=Math.round(r[2]*255),n[o*4+3]=Math.round(r[3]*255)}return n}var it,Ee=G(()=>{\"use strict\";Ni();it=[{offset:0,color:[3/255,102/255,214/255,1]},{offset:1,color:[255/255,127/255,14/255,1]}]});function Lu(e){return isFinite(e)?e<0?0:e>1?1:e:.5}function bs(e){return!isFinite(e)||e<0?1:e}function gs(e){let t=(r,s)=>e[r]||s,n=e[\"--psp-charts--gradient--background\"]||e[\"--psp-charts--full-gradient--background\"]||\"linear-gradient(#0366d6 0%, #ff7f0e 100%)\",o=cs(n),i=[];for(let r=1;;r++){let s=e[`--psp-charts--series-${r}--color`];if(!s)break;i.push(io(s))}return{fontFamily:t(\"--psp-charts--font-family\",t(\"font-family\",\"monospace\")),backgroundColor:t(\"--psp--background-color\",\"rgba(255, 255, 255, 1)\"),It:t(\"--psp-charts--axis-ticks--color\",\"rgba(160, 0, 0, 0.8)\"),Le:t(\"--psp--color\",\"rgba(180, 0, 0, 0.9)\"),Jn:t(\"--psp-charts--axis-lines--color\",\"rgba(160, 0, 0, 0.4)\"),un:t(\"--psp-charts--gridline--color\",\"rgba(255, 0, 0, 1)\"),H:o,mn:t(\"--psp-charts--legend--color\",\"rgba(180, 180, 180, 0.9)\"),nr:t(\"--psp-charts--legend-border--color\",\"rgba(128,128,128,0.3)\"),Kn:t(\"--psp-charts--tooltip--background\",\"rgba(155,155,155,0.8)\"),wi:t(\"--psp-charts--tooltip--color\",\"#161616\"),Ri:t(\"--psp-charts--tooltip--border-color\",\"#fff\"),Qn:Lu(parseFloat(t(\"--psp-charts--area--opacity\",\"0.85\"))),Mi:bs(parseFloat(t(\"--psp-charts--heatmap-gap--px\",\"0\"))),Fi:bs(parseFloat(t(\"--psp-charts--sunburst-gap--px\",\"1\"))),ke:i}}var hs=G(()=>{\"use strict\";Ni();Ee()});function ys(e,t,n){let o=st.get(e);o?(o.fullRender=t,o.render2D=n):(o={glManager:e,fullRender:t,render2D:n,waiters:[]},st.set(e,o));let i=Promise.withResolvers();return o.waiters.push(i),ro||(ro=As(vs)),i.promise}function Cs(e,t){if(!so.has(e)){t();return}let n=Kt.get(e);n||(n=[],Kt.set(e,n)),n.push(t)}function _s(e){let t=st.get(e);if(t){st.delete(e);for(let n of t.waiters)n.resolve()}Kt.delete(e),so.delete(e)}async function vs(){let e=Array.from(st.values());st.clear();let t=new Map;for(let n of e){if(n.glManager.isContextLost()){for(let r of n.waiters)r.resolve();continue}let o=n.glManager.backendId,i=t.get(o);i?i.push(n):t.set(o,[n])}await Promise.all(Array.from(t.values()).map(Tu)),ro=0,st.size>0&&(ro=As(vs))}async function Tu(e){for(let t of e)await Ru(t)}async function Ru(e){so.add(e.glManager);try{e.glManager.beginFrame(),e.fullRender()}catch(t){console.error(\"scheduler: fullRender threw\",t);for(let n of e.waiters)n.reject(t);xs(e.glManager);return}try{await e.glManager.awaitGpuFence(),e.render2D(),e.glManager.endFrame();for(let t of e.waiters)t.resolve()}catch(t){console.error(\"scheduler: present failed\",t);try{e.glManager.endFrame()}catch{}for(let n of e.waiters)n.reject(t)}finally{xs(e.glManager)}}function xs(e){so.delete(e);let t=Kt.get(e);if(t){Kt.delete(e);for(let n of t)try{n()}catch(o){console.error(\"scheduler: deferred op threw\",o)}}}function As(e){return typeof requestAnimationFrame==\"function\"?requestAnimationFrame(e):setTimeout(e,16)}var st,ro,so,Kt,Ui=G(()=>{\"use strict\";st=new Map,ro=0,so=new Set,Kt=new Map});var Ls,wu,Mu,Te,Jt=G(()=>{\"use strict\";ss();as();Ae();eo();fs();Ct();hs();Ui();Ls=!0,wu=(()=>{if(Ls)return me;{let e=Gi(\"float\");return t=>e.format(t)}})(),Mu=(()=>{if(Ls)return ye;{let e=Wi();return t=>e.format(t)}})(),Te=class{constructor(){c(this,\"t\",null);c(this,\"j\",null);c(this,\"c\",null);c(this,\"fn\",[]);c(this,\"Si\",{});c(this,\"g\",null);c(this,\"cn\",[]);c(this,\"I\",[]);c(this,\"_\",[]);c(this,\"B\",[]);c(this,\"Ne\",{});c(this,\"eo\",!1);c(this,\"to\",!1);c(this,\"ht\",{});c(this,\"Oo\",{});c(this,\"Vo\",new Map);c(this,\"no\");c(this,\"G\",{...us});c(this,\"h\",{...ms});c(this,\"T\",new oo);c(this,\"Ho\",null);c(this,\"oo\",Promise.resolve());c(this,\"dn\",null);c(this,\"De\",null)}setGridlineCanvas(t){this.j=t}setChromeCanvas(t){this.c=t}setTheme(t){this.Si=t,this.dn=null}setZoomController(t){this.g=t,t.configure(this.getZoomConfig())}getZoomControllerForFacet(t){if(this.G.zoom_mode===\"shared\")return this.g;if(!this.g)return null;let n=this.cn[t];return n||(n=new yt,n.configure(this.getZoomConfig()),this.cn[t]=n),n}computeEffectiveFacetFlags(){let t=this.G.zoom_mode===\"independent\",n=!t&&this.G.shared_x_axis,o=!t&&this.G.shared_y_axis;return this.eo=n,this.to=o,{independentZoom:t,effectiveSharedX:n,effectiveSharedY:o}}syncFacetZoomLayouts(t){let n=this.G.zoom_mode===\"independent\";for(let o=0;o<t.length;o++)if(this.getZoomControllerForFacet(o)?.updateLayout(t[o].layout),!n)return}setZoomBaseDomain(t,n,o,i){this.g&&this.g.setBaseDomain(t,n,o,i);for(let r of this.cn)r&&r.setBaseDomain(t,n,o,i)}getZoomConfig(){return{}}setColumnSlots(t){this.I=t}setViewPivots(t,n){this._=t,this.B=n}setColumnTypes(t){this.Ne=t,this.Ii()}resetExpandedDomain(){}setGroupByTypes(t){this.ht=t}setColumnsConfig(t){this.Oo=t??{},this.Ii()}Ii(){this.Vo=new Map;for(let[t,n]of Object.entries(this.Oo)){let o=this.Ne[t]??this.ht[t],i=this.or(o,n);i&&this.Vo.set(t,i)}}or(t,n){if(!(!t||!n)){if(t===\"integer\"||t===\"float\"){let o=n.number_format;if(!o)return;let i=Gi(t,o);return r=>i.format(r)}if(t===\"datetime\"){let o=n.date_format;if(!o)return;let i=Wi(o);return r=>i.format(r)}if(t===\"date\"){let o=n.date_format;if(!o)return;let i=rs(o);return r=>i.format(r)}}}getColumnFormatter(t,n=\"value\"){if(t){let r=this.Vo.get(ki(t));if(r)return r}if(n===\"tick\")return;let o=t?ki(t):void 0,i=o?this.Ne[o]??this.ht[o]:void 0;return i===\"date\"||i===\"datetime\"?Mu:wu}setDefaultChartType(t){this.no=t}setFacetConfig(t){this.G={...t}}setPluginConfig(t){this.h={...t},this.G={...this.G,facet_mode:t.facet_mode,zoom_mode:t.facet_zoom_mode},this.io=t.series_zoom_mode===\"dynamic\"}A(){return this.dn||(this.dn=gs(this.Si)),this.dn}invalidateTheme(){this.dn=null}setView(t){this.De&&this.De.dispose(),this.De=new no(t);let n=this.T.isPinned;this.T.dismiss(),n&&this.emitUnselect()}deselect(){this.T.dismiss()}tooltipCallbacks(){return{onHover:()=>{},onLeave:()=>{}}}attachTooltip(t){this.T.attach(this.tooltipCallbacks()),this.T.setHost(t),this.Ho=t}async buildClickDetail(t){let n={};if(t.rowIdx!=null&&t.rowIdx>=0&&this.De)try{let i=await this.De.fetchRow(t.rowIdx);n=Object.fromEntries(i)}catch{n={}}let o=[];for(let i=0;i<this._.length;i++){let r=t.groupByValues[i];r!=null&&r!==\"\"&&o.push([this._[i],\"==\",r])}for(let i=0;i<this.B.length;i++){let r=t.splitByValues[i];r!=null&&r!==\"\"&&o.push([this.B[i],\"==\",r])}return{row:n,column_names:[t.columnName],config:{filter:o}}}emitUserClick(t){let n={row:t.row,column_names:t.column_names,config:t.config};this.Ho?.emitUserClick?.(n)}emitUserSelect(t){let n={selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig};this.Ho?.emitUserSelect?.(n)}emitClickAndSelect(t){let n=this.oo.then(async()=>{let o=await this.buildClickDetail(t);this.emitUserClick(o),this.emitUserSelect({selected:!0,row:o.row,column_names:o.column_names,insertConfig:o.config})});return this.oo=n.catch(o=>{console.error(\"emitClickAndSelect failed\",o)}),n}emitUnselect(t={}){let n=this.oo.then(()=>{this.emitUserSelect({selected:!1,row:t.row??{},column_names:t.column_names??[],insertConfig:{filter:[]}})});this.oo=n.catch(o=>{console.error(\"emitUnselect failed\",o)})}requestRender(t){return ys(t,()=>{this.fn=[],this.Dt(t)},()=>this.Di())}pe(t){this.fn.push(t)}Di(){let t=this.fn;this.fn=[];for(let n of t)n()}renderFrameSync(t){this.fn=[],this.Dt(t),this.Di()}destroy(){this.T.detach(),this.T.dismiss(),this.De&&(this.De.dispose(),this.De=null),this.destroyInternal()}}});var ao,Ts=G(()=>{\"use strict\";ao=class{constructor(t,n,o,i,r){c(this,\"Qe\",new Map);c(this,\"be\");c(this,\"Te\");c(this,\"Bt\");c(this,\"Bi\");this.be=t,this.Te=o,this.Bt=r,this.Bi=Math.max(1,Math.ceil((n-t)/r))}Pi(t,n){return n*this.Bi+t}insert(t,n,o){let i=Math.floor((n-this.be)/this.Bt),r=Math.floor((o-this.Te)/this.Bt),s=this.Pi(i,r),a=this.Qe.get(s);a||(a=[],this.Qe.set(s,a)),a.push(t)}query(t,n,o,i,r,s,a){let l=Math.ceil(o/i/this.Bt),u=Math.ceil(o/r/this.Bt),m=Math.floor((t-this.be)/this.Bt),f=Math.floor((n-this.Te)/this.Bt),p=-1,d=o*o;for(let b=f-u;b<=f+u;b++)for(let x=m-l;x<=m+l;x++){let h=this.Qe.get(this.Pi(x,b));if(h)for(let g of h){let y=(s[g]-t)*i,_=(a[g]-n)*r,C=y*y+_*_;C<d&&(d=C,p=g)}}return p}}});var lo,Rs=G(()=>{\"use strict\";Ts();lo=class{constructor(){c(this,\"pn\",null);c(this,\"bn\",!0)}markDirty(){this.bn=!0}get isDirty(){return this.bn}rebuild(t,n,o){if(n===0){this.pn=null,this.bn=!1;return}let i=t.xMax-t.xMin||1,r=t.yMax-t.yMin||1,a=(i+r)/2/Math.max(1,Math.sqrt(n)),l=new ao(t.xMin,t.xMax,t.yMin,t.yMax,a);o((u,m,f)=>l.insert(u,m,f)),this.pn=l,this.bn=!1}query(t,n,o,i,r,s,a){return!this.pn||!s||!a?-1:this.pn.query(t,n,o,i,r,s,a)}clear(){this.pn=null,this.bn=!0}}});function He(e,t,n=[]){let o=new Map;for(let r of e.keys()){if(r.startsWith(\"__\"))continue;let s=r.lastIndexOf(\"|\");if(s===-1)continue;let a=r.substring(0,s);o.has(a)||o.set(a,new Set),o.get(a).add(r)}let i=[];for(let[r,s]of o){let a=new Map,l=!0;for(let u of t){if(!u)continue;let m=`${r}|${u}`,f=e.get(m);if(!s.has(m)||!f?.values){l=!1;break}a.set(u,m)}if(l){for(let u of n){if(!u)continue;let m=`${r}|${u}`;s.has(m)&&e.get(m)?.values&&a.set(u,m)}i.push({prefix:r,colNames:a})}}return i}var Qt=G(()=>{\"use strict\"});var uo,ws=G(()=>{\"use strict\";uo=class{constructor(t){c(this,\"data\");c(this,\"dictionary\",[]);c(this,\"dictMap\",new Map);this.data=new Int32Array(t),this.data.fill(-1)}set(t,n){let o=this.dictMap.get(n);return o===void 0&&(o=this.dictionary.length,this.dictionary.push(n),this.dictMap.set(n,o)),this.data[t]=o,o}get(t){let n=this.data[t];return n<0?null:this.dictionary[n]}}});function Ms(e,t,n,o){let i;if(!e)i=\"(null)\";else{let s=e.valid;if(!(s?!!(s[t>>3]>>(t&7)&1):!0))i=\"(null)\";else if(e.indices&&e.dictionary)i=e.dictionary[e.indices[t]]??\"(null)\";else if(e.values){let l=e.values[t];i=l==null?\"(null)\":String(l)}else i=\"(null)\"}let r=o.get(i);return r===void 0&&(r=n.length,n.push(i),o.set(i,r)),r}function Fu(e,t,n,o,i,r){let s=t?[t,n]:[n],a=[];return o&&a.push(o),i&&a.push(i),r&&a.push(r),He(e,s,a).map(l=>({prefix:l.prefix,xColName:t?l.colNames.get(t):\"\",yColName:l.colNames.get(n),colorColName:o?`${l.prefix}|${o}`:\"\",sizeColName:i?`${l.prefix}|${i}`:\"\",labelColName:r?`${l.prefix}|${r}`:\"\"}))}function Fs(e,t,n,o){e.glyph.ensureProgram(e,t);let i=e.a,r=e.Z;e.h.domain_mode===\"expand\"?(e.be=e.gn,e.et=e.hn,e.Te=e.xn,e.tt=e.yn,e.b=e.ro,e.p=e.so,e.nt=e.ao,e.ot=e.uo):(e.be=1/0,e.et=-1/0,e.Te=1/0,e.tt=-1/0,e.b=1/0,e.p=-1/0,e.nt=1/0,e.ot=-1/0,e.gn=1/0,e.hn=-1/0,e.xn=1/0,e.yn=-1/0,e.ro=1/0,e.so=-1/0,e.ao=1/0,e.uo=-1/0),e.w=NaN,e.M=NaN,e.xt=0,e.qt.clear(),e.Yo=0;let a=e.I,l=a[0]||\"\",u=a[1]||\"\",m=a[2]||\"\",f=a[3]||\"\",p=a[4]||\"\";e.Ue=l,e.Be=u,e.Ei=!l,e.Pe=!!l&&e.Ne[l]===\"string\",e.ge=!!u&&e.Ne[u]===\"string\",e.Kt=[],e.Jt=[],e.Gi=new Map,e.Wi=new Map,e.it=null,e.rt=null,e.Pe&&(e.w=0,e.be=0,e.et=0,e.gn=1/0,e.hn=-1/0),e.ge&&(e.M=0,e.Te=0,e.tt=0,e.xn=1/0,e.yn=-1/0);let d=t.v.totalCapacity||o;if(e.B.length>0){if(e.L=Fu(n,l,u,m,f,p),e.L.length===0){e.R=0,e.U=[];return}if(e.$e=e.L[0].xColName,e.Oe=e.L[0].yColName,e.a=m,e.ne=f,e.mo=p,e.Z=!1,m){let h=n.get(e.L[0].colorColName);e.Z=h?.type===\"string\"}t.ensureBufferCapacity(d*e.L.length)}else if(e.L=[],e.$e=l,e.Oe=u,e.a=m,e.ne=f,e.mo=p,e.Z=!1,e.a){let h=n.get(e.a);e.Z=h?.type===\"string\"}(e.a!==i||e.Z!==r)&&(e.f=new Map);let b=Math.max(1,e.L.length);e.R=d,e.U=new Array(b).fill(0);let x=b*d;e.O=new Float32Array(x),e.V=new Float32Array(x),e.yt=new Float32Array(x),e.Pt=new Int32Array(x),e.Et=p?new uo(x):null}function Ss(e,t,n,o,i,r){if(!e.Oe)return;let s=i;if(s===0||e.R===0)return;let a=e.L.length>0,l=[];if(a)for(let b of e.L){let x=b.xColName?n.get(b.xColName):null,h=n.get(b.yColName);if(!h||!e.ge&&!h.values)continue;let g=b.sizeColName?n.get(b.sizeColName):null,y=b.colorColName?n.get(b.colorColName)??null:null,_=b.labelColName?n.get(b.labelColName)??null:null;l.push({xCol:x?.values??null,yCol:h.values??null,xColData:x??null,yColData:h,xValid:x?.valid,yValid:h.valid,colorCol:y,sizeCol:g?.values??null,labelCol:_})}else{let b=e.$e?n.get(e.$e):null,x=e.Oe?n.get(e.Oe):null;if(!x||!e.ge&&!x.values)return;let h=e.a?n.get(e.a)??null:null,g=e.mo?n.get(e.mo)??null:null;l.push({xCol:b?.values??null,yCol:x.values??null,xColData:b??null,yColData:x,xValid:b?.valid,yValid:x?.valid,colorCol:h,sizeCol:null,labelCol:g})}if(l.length===0)return;e.ki<s&&(e.zo=new Float32Array(s*2),e.Xo=new Float32Array(s),e.$o=new Float32Array(s),e.ki=s);let u=e.zo,m=e.Xo,f=e.$o,p=!a&&e.ne?n.get(e.ne)?.values??null:null;if(e.Z&&e.a){for(let b of l){let x=b.colorCol?.dictionary;if(x)for(let h=0;h<x.length;h++){let g=x[h];e.f.has(g)||e.f.set(g,e.f.size)}}e.f.size>0&&(e.b=0,e.p=e.f.size-1)}!e.a&&e.L.length>1&&(e.b=0,e.p=e.L.length-1);for(let b=0;b<l.length;b++){let x=l[b],h=e.U[b]??0,g=b*e.R,y=e.R-h;if(y<=0)continue;let _=x.colorCol?.valid,C=0;for(let T=0;T<s&&C<y;T++){let L=T;if(!e.ge&&x.yValid&&!(x.yValid[L>>3]>>(L&7)&1)||!e.Pe&&x.xCol&&x.xValid&&!(x.xValid[L>>3]>>(L&7)&1))continue;let R=_!==void 0&&!(_[L>>3]>>(L&7)&1),F;if(e.ge)F=Ms(x.yColData,L,e.Jt,e.Wi);else if(x.yCol){if(F=x.yCol[L],isNaN(F))continue}else continue;let I;if(e.Pe)I=Ms(x.xColData,L,e.Kt,e.Gi);else if(x.xCol){if(I=x.xCol[L],isNaN(I))continue}else I=o+L;let[S,D]=e.projectPoint(I,F);if(isNaN(S)||isNaN(D))continue;S<e.be&&(e.be=S),S>e.et&&(e.et=S),D<e.Te&&(e.Te=D),D>e.tt&&(e.tt=D),isNaN(e.w)&&(e.w=S),isNaN(e.M)&&(e.M=D);let B=S-e.w,N=D-e.M,k=g+h+C;e.O[k]=B,e.V[k]=N,e.Pt[k]=o+L,u[C*2]=B,u[C*2+1]=N;let Y=x.colorCol;if(R)m[C]=.5,e.yt[k]=.5;else if(Y&&!e.Z&&Y.values){let W=Y.values[L];m[C]=W,e.yt[k]=W,W<e.b&&(e.b=W),W>e.p&&(e.p=W)}else if(Y&&e.Z&&Y.indices&&Y.dictionary){let W=Y.dictionary[Y.indices[L]];e.f.has(W)||(e.f.set(W,e.f.size),e.p=e.f.size-1);let V=e.f.get(W);m[C]=V,e.yt[k]=V}else m[C]=b,e.yt[k]=b;if(e.Et&&x.labelCol){let W=x.labelCol,V=W.valid;!(V!==void 0&&!(V[L>>3]>>(L&7)&1))&&W.indices&&W.dictionary&&e.Et.set(k,W.dictionary[W.indices[L]])}if(x.sizeCol){let W=x.sizeCol[L];f[C]=W,W<e.nt&&(e.nt=W),W>e.ot&&(e.ot=W)}else if(p){let W=p[L];f[C]=W,W<e.nt&&(e.nt=W),W>e.ot&&(e.ot=W)}else f[C]=0;C++}if(C===0)continue;let v=(g+h)*2*Float32Array.BYTES_PER_ELEMENT;t.v.upload(\"a_position\",u.subarray(0,C*2),v,2);let A=(g+h)*Float32Array.BYTES_PER_ELEMENT;t.v.upload(\"a_color_value\",m.subarray(0,C),A),t.v.upload(\"a_size_value\",f.subarray(0,C),A),e.U[b]=h+C,e.U[b]>e.Yo&&(e.Yo=e.U[b])}let d=0;for(let b of e.U)d+=b;e.xt=d,t.uploadedCount=d,e.qt.markDirty(),isFinite(e.be)&&e.setZoomBaseDomain(e.be,e.et,e.Te,e.tt)}var Is=G(()=>{\"use strict\";Qt();ws()});function _t(e,t,n,o,i){let r=e.getContext(\"2d\");r&&(r.save(),r.setTransform(1,0,0,1,0,0),r.scale(i,i),r.font=`11px ${o.fontFamily}`,r.fillStyle=o.Le,r.textAlign=\"center\",r.textBaseline=\"middle\",r.fillText(t,n.x+n.width/2,n.y+n.height/2),r.restore())}var mo=G(()=>{\"use strict\"});var ne,Ye=G(()=>{\"use strict\";ne=class{constructor(t,n,o){c(this,\"margins\");c(this,\"e\");c(this,\"cssWidth\");c(this,\"cssHeight\");c(this,\"Y\",0);c(this,\"J\",1);c(this,\"q\",0);c(this,\"Q\",1);this.cssWidth=t,this.cssHeight=n;let r=(o.leftExtra??55)+(o.hasYLabel?16:0),a=(o.bottomExtra??24)+(o.hasXLabel?18:0),l=0,u=o.rightExtra??(o.hasLegend?80:16),m=o.originX??0,f=o.originY??0,p=o.cellWidth??t,d=o.cellHeight??n,b=m+r,x=f+l,h=Math.max(1,p-r-u),g=Math.max(1,d-l-a),y=t-(b+h),_=n-(x+g);this.margins={top:x,right:y,bottom:_,left:b},this.e={x:b,y:x,width:h,height:g}}buildProjectionMatrix(t,n,o,i,r,s,a=.02,l=0,u=0){let m=n-t,f=i-o;m===0&&(m=1),f===0&&(f=1);let p=m*a,d=f*a,b=s&&r===\"y\"&&o>=0,x=s&&r===\"y\"&&i<=0,h=s&&r===\"x\"&&t>=0,g=s&&r===\"x\"&&n<=0;t-=p,n+=p,o-=d,i+=d,b?(o=0,i+=d):x&&(i=0,o-=d),h?(t=0,n+=p):g&&(n=0,t-=p),this.Y=t,this.J=n,this.q=o,this.Q=i;let y=2*this.margins.left/this.cssWidth-1,_=1-2*this.margins.right/this.cssWidth,C=2*this.margins.bottom/this.cssHeight-1,v=1-2*this.margins.top/this.cssHeight,A=(_-y)/(n-t),T=(v-C)/(i-o),L=y-A*(t-l),R=C-T*(o-u);return new Float32Array([A,0,0,0,0,T,0,0,0,0,-1,0,L,R,0,1])}P(t,n){let{x:o,y:i,width:r,height:s}=this.e,a=(t-this.Y)/(this.J-this.Y),l=(n-this.q)/(this.Q-this.q);return{px:o+a*r,py:i+(1-l)*s}}}});function en(e){return e.cells.filter(t=>t.isBottomEdge).map(t=>t.layout)}function tn(e){return e.cells.filter(t=>t.isLeftEdge).map(t=>t.layout)}function Gu(e,t,n,o){if(e<=1)return{cols:1,rows:1};let i=1,r=e,s=1/0,a=e;for(let l=1;l<=e;l++){let u=Math.ceil(e/l),m=Math.max(1,(t-(l-1)*o)/l),f=Math.max(1,(n-(u-1)*o)/u),p=m/f,d=Math.max(p,1/p),b=l*u;(d<s||d===s&&b<a)&&(i=l,r=u,s=d,a=b)}return{cols:i,rows:r}}function Re(e,t){let n=e.length,{cssWidth:o,cssHeight:i}=t;if(n<=0||o<=0||i<=0)return{cells:[]};let r=t.titleBand??Pu,s=t.hasLegend?Eu:0,a=t.xAxis??\"cell\",l=t.yAxis??\"cell\",u=a===\"none\"&&l===\"none\",m=l===\"outer\"?Su+(t.hasYLabel?Du:0):0,f=a===\"outer\"?Iu+(t.hasXLabel?Bu:0):0,p=0,d=s,b=m,x=p,h=Math.max(1,o-m-d),g=Math.max(1,i-p-f),y=Math.max(0,t.gap??0),{cols:_,rows:C}=Gu(n,h,g,y),v=Math.max(0,_-1)*y,A=Math.max(0,C-1)*y,T=Math.max(1,(h-v)/_),L=Math.max(1,(g-A)/C),R=[];for(let D=0;D<n;D++){let B=Math.floor(D/_),N=D-B*_,k=B===C-1||D+_>=n,Y=N===0,W=b+N*(T+y),V=x+B*(L+y),O=V+r,X=W,q=T,le=Math.max(1,L-r),Fe=new ne(o,i,{hasXLabel:a===\"cell\"&&t.hasXLabel===!0,hasYLabel:l===\"cell\"&&t.hasYLabel===!0,hasLegend:!1,leftExtra:l===\"cell\"?void 0:0,bottomExtra:a===\"cell\"?void 0:0,rightExtra:u?0:void 0,originX:X,originY:O,cellWidth:q,cellHeight:le}),_e=r>0?{x:X,y:V,width:q,height:r}:void 0;R.push({index:D,label:e[D],layout:Fe,titleRect:_e,isLeftEdge:Y,isBottomEdge:k})}let F=t.hasLegend?{x:b+h,y:p,width:s,height:g}:void 0,I=a===\"outer\"?{x:b,y:x+g,width:h,height:f}:void 0;return{cells:R,legendRect:F,outerXAxisRect:I,outerYAxisRect:l===\"outer\"?{x:0,y:x,width:m,height:g}:void 0}}var Su,Iu,Du,Bu,Pu,Eu,vt=G(()=>{\"use strict\";Ye();Su=55,Iu=24,Du=16,Bu=18,Pu=18,Eu=96});function Wu(e,t){if(t<=0)return[];let n=new Array(t);for(let o=0;o<t;o++){let i=t===1?.5:o/(t-1),r=Le(e,i);n[o]=[r[0],r[1],r[2]]}return n}function de(e,t,n){if(e.length>0){if(e.length>=n)return e.slice(0,n);let o=new Array(n);for(let i=0;i<n;i++)o[i]=e[i%e.length];return o}return Wu(t,n)}var nn=G(()=>{\"use strict\";Ee()});function at(e){e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)}function lt(e,t,n,o){e.enable(e.SCISSOR_TEST),e.scissor(Math.round(t.margins.left*n),Math.round(t.margins.bottom*n),Math.round(t.e.width*n),Math.round(t.e.height*n));try{o()}finally{e.disable(e.SCISSOR_TEST)}}function ze(e,t,n,o){at(e),lt(e,t,n,o)}var on=G(()=>{\"use strict\"});function rn(e,t,n){let o=e.gl,i;if(t?.texture){if(i=t.texture,t.lastStops===n)return t}else i=o.createTexture();let r=ps(n,Ds);return o.bindTexture(o.TEXTURE_2D,i),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,Ds,1,0,o.RGBA,o.UNSIGNED_BYTE,r),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),{texture:i,lastStops:n}}function Ge(e,t,n,o=0){let i=e.gl;i.activeTexture(i.TEXTURE0+o),i.bindTexture(i.TEXTURE_2D,t),i.uniform1i(n,o)}var Ds,At=G(()=>{\"use strict\";Ee();Ds=256});function ue(e,t,n){e.width=Math.round(t.cssWidth*n),e.height=Math.round(t.cssHeight*n);let o=e.getContext(\"2d\");return o?(o.scale(n,n),o.clearRect(0,0,t.cssWidth,t.cssHeight),o):null}function re(e,t){let n=e.getContext(\"2d\");return n?(n.setTransform(t,0,0,t,0,0),n):null}var ut=G(()=>{\"use strict\"});function fo(e,t,n,o,i,r,s){let a=i===\"bottom\"?1:-1;e.textAlign=\"center\",e.textBaseline=i===\"bottom\"?\"top\":\"bottom\";let l=a*8;for(let u of n){let m=r(u);m<t.x-1||m>t.x+t.width+1||(e.beginPath(),e.moveTo(m,o),e.lineTo(m,o+a*5),e.stroke(),e.fillText(s(u),m,o+l))}}function co(e,t,n,o,i,r,s){let a=i===\"left\"?-1:1;e.textAlign=i===\"left\"?\"right\":\"left\",e.textBaseline=\"middle\";let l=a*8;for(let u of n){let m=r(u);m<t.y-1||m>t.y+t.height+1||(e.beginPath(),e.moveTo(o,m),e.lineTo(o+a*5,m),e.stroke(),e.fillText(s(u),o+l,m))}}function Lt(e,t,n,o){for(let i of n){let r=Math.round(o(i))+.5;r<t.x||r>t.x+t.width||(e.beginPath(),e.moveTo(r,t.y),e.lineTo(r,t.y+t.height),e.stroke())}}function Tt(e,t,n,o){for(let i of n){let r=Math.round(o(i))+.5;r<t.y||r>t.y+t.height||(e.beginPath(),e.moveTo(t.x,r),e.lineTo(t.x+t.width,r),e.stroke())}}var po=G(()=>{\"use strict\"});function Rt(e,t,n){let{e:o}=n,i=Math.max(2,Math.floor(o.width/90)),r=Math.max(2,Math.floor(o.height/60));return{xTicks:ie(e.min,e.max,i),yTicks:ie(t.min,t.max,r)}}function Oi(e,t,n,o,i,r){let s=re(e,r);if(!s)return;let{e:a}=t;s.strokeStyle=i.un,s.lineWidth=1,Lt(s,a,n,l=>t.P(l,0).px),Tt(s,a,o,l=>t.P(0,l).py)}function Bs(e,t,n){if(n)return n;let o=t.length>1?t[1]-t[0]:0;return e.isDate?i=>ye(i,o):me}function Ps(e,t,n,o,i,r,s,a,l){let{It:u,Le:m,Jn:f,fontFamily:p}=s,d=Bs(t,n,l);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(r.x,i),e.lineTo(r.x+r.width,i),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${p}`;for(let b of o)fo(e,b.e,n,i,\"bottom\",x=>b.P(x,0).px,d);a&&t.label&&(e.fillStyle=m,e.font=`13px ${p}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(t.label,a.cx,a.baselineY))}function Es(e,t,n,o,i,r,s,a,l){let{It:u,Le:m,Jn:f,fontFamily:p}=s,d=Bs(t,n,l);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(i,r.y),e.lineTo(i,r.y+r.height),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${p}`;for(let b of o)co(e,b.e,n,i,\"left\",x=>b.P(0,x).py,d);a&&t.label&&(e.fillStyle=m,e.font=`13px ${p}`,e.save(),e.translate(14,a.pivotY),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(t.label,0,0),e.restore())}function Vi(e,t,n,o,i,r,s,a){let l=re(e,s);if(!l)return;let{e:u}=n;Ps(l,t,o,[n],u.y+u.height,u,i,r?{cx:u.x+u.width/2,baselineY:n.cssHeight-2}:null,a)}function Hi(e,t,n,o,i,r,s,a){let l=re(e,s);if(!l)return;let{e:u}=n;Es(l,t,o,[n],u.x,u,i,r?{pivotY:u.y+u.height/2}:null,a)}function sn(e,t,n,o,i,r,s,a,l){let u=re(e,a);u&&Ps(u,n,o,i,t.y,t,r,s?{cx:t.x+t.width/2,baselineY:t.y+t.height-2}:null,l)}function an(e,t,n,o,i,r,s,a,l){let u=re(e,a);u&&Es(u,n,o,i,t.x+t.width,t,r,s?{pivotY:t.y+t.height/2}:null,l)}var Yi=G(()=>{\"use strict\";Ae();ut();po()});function zi(e,t,n,o,i){if(i===0)return{x:e-n/2,y:t,width:n,height:o};if(i===90)return{x:e-o/2,y:t,width:o,height:n};let r=(n+o)/Math.SQRT2;return{x:e-r,y:t,width:r,height:r}}function Xi(e,t){return e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height}function Gs(e,t){return e.x+e.width+14>t.x+t.width}function $i(e,t){return e.x>=t.x&&e.x+e.width<=t.x+t.width&&e.y>=t.y&&e.y+e.height<=t.y+t.height}function mt(e,t,n){if(n<=0)return\"\";if(e.measureText(t).width<=n)return t;let o=0,i=t.length;for(;o<i;){let r=o+i+1>>1,s=t.slice(0,r)+\"\\u2026\";e.measureText(s).width<=n?o=r:i=r-1}return o===0?\"\":t.slice(0,o)+\"\\u2026\"}function Ws(e,t,n,o){if(o<=0||n<=0)return[];if(e.measureText(t).width<=n)return[t];let i=[],r=t;for(;r.length>0&&i.length<o;){let s=i.length===o-1,a=r.length;for(;a>0&&e.measureText(r.slice(0,a)).width>n;)a--;if(a===0&&(a=1),a===r.length){i.push(r);break}let l=a,u=r.lastIndexOf(\" \",a);if(u>0&&(l=u),s){i.push(mt(e,r,n));break}i.push(r.slice(0,l)),r=r.slice(l).trimStart()}return i.length===1&&i[0].length<=2?[]:i}var bo=G(()=>{\"use strict\"});function go(e,t,n,o){let i=[];if(o<=n)return i;let r=n,s=e[n];for(let a=n+1;a<o;a++){let l=e[a];l!==s&&(i.push({startIdx:r,endIdx:a-1,label:t[s]??\"\"}),r=a,s=l)}return i.push({startIdx:r,endIdx:o-1,label:t[s]??\"\"}),i}function ln(e,t,n){if(n<t)return[];let o=[];for(let i of e){if(i.endIdx<t||i.startIdx>n)continue;let r=i.startIdx<t?t:i.startIdx,s=i.endIdx>n?n:i.endIdx;r===i.startIdx&&s===i.endIdx?o.push(i):o.push({startIdx:r,endIdx:s,label:i.label})}return o}var un=G(()=>{\"use strict\"});function ji(e,t){return e.P(t,0).px}function Zi(e,t){return e.P(0,t).py}function Hu(e,t,n){let o=Math.max(0,n-100);return e*16>o?{size:t*6.62+10,rotation:90}:e*(t*6+10)>o?{size:t*4+20,rotation:45}:{size:ku,rotation:0}}function ks(e,t){let n=e.levels.length,o=[];for(let i=0;i<n;i++){let r=e.levels[i];i===n-1?o.push(Hu(e.numRows,r.maxLabelChars,t)):o.push({size:Nu,rotation:0})}return o}function Ns(e){let t=e.levels.length,n=[],o=6.2;for(let i=0;i<t;i++)if(i===t-1){let r=e.levels[i].maxLabelChars;n.push(Math.max(Uu,r*o+Vu))}else n.push(Ou);return n}function Us(e){let t=0;for(let n of e)t+=n;return t}function We(e,t){return e.numRows===0||e.levels.length===0?24:Us(ks(e,t).map(n=>n.size))}function Mt(e){return e.numRows===0||e.levels.length===0?55:Us(Ns(e))}function Yu(e,t,n,o){let i=t-e+1;if(i<=0)return[];let r=Math.max(1,Math.floor(n/o));if(i<=r){let l=[];for(let u=e;u<=t;u++)l.push(u);return l}let s=Math.ceil(i/r),a=[];for(let l=e;l<=t;l+=s)a.push(l);return a}function Os(e,t){return e.labels[t]??\"\"}function Vs(e,t,n,o){let i=o?Math.min(t,n):t,r=o?Math.max(t,n):n,s=Math.max(0,Math.ceil(i)),a=Math.min(e-1,Math.floor(r));return a<s?null:[s,a]}function Hs(e,t,n,o){let i=[];for(let r of e){let s=t(r.startIdx-.5),a=t(r.endIdx+.5),l=Math.max(n,Math.min(s,a)),u=Math.min(o,Math.max(s,a));u>l&&i.push({run:r,nearEdge:s,farEdge:a,nearClip:l,farClip:u})}return i}function pe(e,t,n,o){if(n.numRows===0||n.levels.length===0)return;let{It:i,Le:r,fontFamily:s}=o,{e:a}=t,l=a.y+a.height;e.strokeStyle=i,e.fillStyle=i,e.lineWidth=1,e.font=`${wt}px ${s}`;let u=ks(n,a.width),m=Vs(n.numRows,t.Y,t.J,!1);if(!m)return;let[f,p]=m,d=n.levels.length,b=l;for(let h=d-1;h>=0;h--){let g=n.levels[h],y=u[h],_=b;b+=y.size,h===d-1?zu(e,t,g,f,p,_,y,s,i):Xu(e,t,g,f,p,_,s,i)}let x=n.levelLabels.filter(h=>!!h).join(\" / \");x&&(e.fillStyle=r,e.font=`13px ${s}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(x,a.x+a.width/2,t.cssHeight-2))}function zu(e,t,n,o,i,r,s,a,l){let{e:u}=t,f=Math.max(40,Math.min(n.maxLabelChars*6.2+8,u.width/2)),p=s.rotation===0?Yu(o,i,u.width,f):$u(o,i);e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let h of p){let g=ji(t,h);g<u.x-1||g>u.x+u.width+1||(e.moveTo(g,r),e.lineTo(g,r+ho))}e.stroke(),e.font=`${wt}px ${a}`;let d=r+ho+3,b={x:u.x,width:u.width,y:r,height:9999},x=[];for(let h of p){let g=ji(t,h);if(g<u.x-1||g>u.x+u.width+1)continue;let y=Os(n,h);if(!y)continue;let _=e.measureText(y).width,C=zi(g,d,_,qi,s.rotation);if($i(C,b)){if(s.rotation===0){if(x.some(v=>Xi(v,C)))continue}else if(x.some(v=>Gs(v,C)))continue;x.push(C),Ys(e,y,g,d,s.rotation,\"center\")}}}function Xu(e,t,n,o,i,r,s,a){let{e:l}=t,u=ln(n.runs,o,i);if(u.length===0)return;let m=Hs(u,b=>ji(t,b),l.x,l.x+l.width);if(m.length===0)return;e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let b of m)e.moveTo(b.nearClip,r+3),e.lineTo(b.farClip,r+3),e.moveTo(b.nearEdge,r),e.lineTo(b.nearEdge,r+3),e.moveTo(b.farEdge,r),e.lineTo(b.farEdge,r+3);e.stroke(),e.font=`${wt}px ${s}`;let f=r+3+4,p=[],d={x:l.x,width:l.width,y:r,height:9999};for(let b of m){let x=(b.nearClip+b.farClip)/2,h=b.run.label;if(!h)continue;let g=b.farClip-b.nearClip-4,y=mt(e,h,g);if(!y)continue;let _=e.measureText(y).width,C=zi(x,f,_,qi,0);$i(C,d)&&(p.some(v=>Xi(v,C))||(p.push(C),Ys(e,y,x,f,0,\"center\")))}}function $u(e,t){let n=[];for(let o=e;o<=t;o++)n.push(o);return n}function we(e,t,n,o){if(n.numRows===0||n.levels.length===0)return;let{It:i,Le:r,fontFamily:s}=o,{e:a}=t,l=a.x;e.strokeStyle=i,e.fillStyle=i,e.lineWidth=1,e.font=`${wt}px ${s}`;let u=Ns(n),m=Vs(n.numRows,t.q,t.Q,!0);if(!m)return;let[f,p]=m,d=n.levels.length,b=l;for(let h=d-1;h>=0;h--){let g=n.levels[h],y=u[h],_=b;b-=y,h===d-1?ju(e,t,g,f,p,_,s,i):Zu(e,t,g,f,p,_,y,s,i)}let x=n.levelLabels.filter(h=>!!h).join(\" / \");x&&(e.fillStyle=r,e.font=`13px ${s}`,e.save(),e.translate(14,a.y+a.height/2),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(x,0,0),e.restore())}function ju(e,t,n,o,i,r,s,a){let{e:l}=t,u=qi+4,m=i-o+1,f=Math.max(1,Math.floor(l.height/u)),p=m<=f?1:Math.ceil(m/f);e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let d=o;d<=i;d+=p){let b=Zi(t,d);b<l.y-1||b>l.y+l.height+1||(e.moveTo(r-ho,b),e.lineTo(r,b))}e.stroke(),e.font=`${wt}px ${s}`,e.textAlign=\"right\",e.textBaseline=\"middle\";for(let d=o;d<=i;d+=p){let b=Zi(t,d);if(b<l.y-1||b>l.y+l.height+1)continue;let x=Os(n,d);x&&e.fillText(x,r-ho-3,b)}}function Zu(e,t,n,o,i,r,s,a,l){let{e:u}=t,m=ln(n.runs,o,i);if(m.length===0)return;let f=Hs(m,d=>Zi(t,d),u.y,u.y+u.height);if(f.length===0)return;e.strokeStyle=l,e.fillStyle=l;let p=r-3;e.beginPath();for(let d of f)e.moveTo(p,d.nearClip),e.lineTo(p,d.farClip),e.moveTo(p,d.nearEdge),e.lineTo(r,d.nearEdge),e.moveTo(p,d.farEdge),e.lineTo(r,d.farEdge);e.stroke(),e.font=`${wt}px ${a}`,e.textAlign=\"right\",e.textBaseline=\"middle\";for(let d of f){let b=(d.nearClip+d.farClip)/2,x=d.run.label;if(!x)continue;let h=s-6,g=mt(e,x,h);g&&e.fillText(g,p-3,b)}}function Ys(e,t,n,o,i,r){if(i===0){e.textAlign=r===\"end\"?\"right\":\"center\",e.textBaseline=\"top\",e.fillText(t,n,o);return}e.save(),e.translate(n,o),e.rotate(-i*Math.PI/180),e.textAlign=\"right\",e.textBaseline=\"middle\",e.fillText(t,-2,0),e.restore()}var ku,Nu,ho,wt,qi,Uu,Ou,Vu,Ft=G(()=>{\"use strict\";bo();un();ku=25,Nu=22,ho=5,wt=11,qi=14,Uu=55,Ou=60,Vu=10});function qu(e){return`rgb(${Math.round(e[0]*255)},${Math.round(e[1]*255)},${Math.round(e[2]*255)})`}function St(e,t,n,o,i,r){let s={x:t.e.x+t.e.width+12,y:t.margins.top+20,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};mn(e,s,n,o,i,r)}function mn(e,t,n,o,i,r=me){let s=e.getContext(\"2d\");if(!s)return;let a=i.mn,l=i.nr,u=i.fontFamily,m=16,f=Math.min(120,t.height*.4),p=t.x,d=t.y;s.fillStyle=a,s.font=`9px ${u}`,s.textAlign=\"left\",s.textBaseline=\"bottom\",s.fillText(n.label,p,d-4);let b=n.max,x=n.min,h=s.createLinearGradient(0,d,0,d+f),g=16;for(let _=0;_<=g;_++){let C=_/g,v=b+C*(x-b),A=rt(v,n.min,n.max),T=Le(o,A);h.addColorStop(C,qu(T))}s.fillStyle=h,s.fillRect(p,d,m,f),s.strokeStyle=l,s.lineWidth=1,s.strokeRect(p,d,m,f),s.fillStyle=a,s.font=`10px ${u}`,s.textAlign=\"left\",s.textBaseline=\"middle\";let y=p+m+5;if(s.fillText(r(n.max),y,d+2),s.fillText(r((n.min+n.max)/2),y,d+f/2),s.fillText(r(n.min),y,d+f-2),n.min<0&&n.max>0){let _=(n.max-0)/(n.max-n.min),C=d+_*f;s.strokeStyle=a,s.lineWidth=1,s.beginPath(),s.moveTo(p+m,C),s.lineTo(p+m+4,C),s.stroke(),s.fillStyle=a,s.fillText(\"0\",y,C)}}function xo(e,t,n,o,i){let r={x:t.e.x+t.e.width+12,y:t.margins.top+10,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};fn(e,r,n,o,i)}function fn(e,t,n,o,i){let r=e.getContext(\"2d\");if(!r||n.size===0)return;let s=i.mn,a=i.fontFamily,l=10,u=18,m=t.x,f=t.y+u/2;r.font=`11px ${a}`,r.textAlign=\"left\",r.textBaseline=\"middle\";for(let[p,d]of n){if(f+l/2>t.y+t.height)break;let b=o[d]??o[d%o.length]??[0,0,0];r.fillStyle=`rgb(${Math.round(b[0]*255)},${Math.round(b[1]*255)},${Math.round(b[2]*255)})`,r.fillRect(m,f-l/2,l,l),r.fillStyle=s,r.fillText(p,m+l+6,f),f+=u}}var yo=G(()=>{\"use strict\";Ae();Ee()});function Xe(e){return isNaN(e)?0:e}function zs(e,t){let n=t.gl,o=t.dpr,i=n.canvas.width/o,r=n.canvas.height/o;if(i<=0||r<=0)return;let s=e.L.length>0,a=e.G.facet_mode,l=s&&a===\"grid\";e.computeEffectiveFacetFlags();let u=e.a!==\"\"&&e.b<e.p,m=l&&e.G.zoom_mode===\"independent\",f;if(e.g&&!m?f=e.g.getVisibleDomain():f={xMin:e.be,xMax:e.et,yMin:e.Te,yMax:e.tt},!isFinite(f.xMin)||!isFinite(f.yMin))return;let p=e.A(),d=p.ke,b=e.Ne[e.Ue]||\"\",x=e.Ne[e.Be]||\"\",h=b===\"date\"||b===\"datetime\",g=x===\"date\"||x===\"datetime\",y=e.Z,_=!y&&!e.a,C=p.H;if(y||_){let v=_?Math.max(1,e.L.length):Math.max(1,e.f.size);if(e.fo&&e.jo===d&&e.Zo===v)C=e.fo;else{let A=de(d,p.H,v);C=ds(A),e.fo=C,e.jo=d,e.Zo=v}}else e.fo=null,e.jo=null,e.Zo=-1;e.oe=rn(t,e.oe,C),l?Qu(e,t,f,p,{xIsDate:h,yIsDate:g,cssWidth:i,cssHeight:r}):(e.m=null,Ju(e,t,f,p,{xIsDate:h,yIsDate:g,cssWidth:i,cssHeight:r,hasColorCol:u})),e.pe(()=>$e(e))}function Co(e,t,n,o){return{min:t,max:n,label:e.Ue||(e.Ei?\"Row\":e.$e||\"\"),isDate:o}}function _o(e,t,n,o){return{min:t,max:n,label:e.Be||e.Oe,isDate:o}}function vo(e,t){let n=0;for(let i of e)i.length>n&&(n=i.length);return{levels:[{labels:e.slice(),runs:[],maxLabelChars:n}],numRows:e.length,levelLabels:[t]}}function Ku(e,t,n,o,i,r,s,a,l){if(e.Pe&&e.it){let u=re(t,l);u&&pe(u,n,e.it,a)}else Vi(t,o,n,r,a,!0,l,e.getColumnFormatter(e.$e,\"tick\"));if(e.ge&&e.rt){let u=re(t,l);u&&we(u,n,e.rt,a)}else Hi(t,i,n,s,a,!0,l,e.getColumnFormatter(e.Oe,\"tick\"))}function Ju(e,t,n,o,i){let r=t.gl,{cssWidth:s,cssHeight:a,xIsDate:l,yIsDate:u,hasColorCol:m}=i;e.it=e.Pe&&e.Kt.length>0?vo(e.Kt,e.Ue||e.$e||\"\"):null,e.rt=e.ge&&e.Jt.length>0?vo(e.Jt,e.Be||e.Oe||\"\"):null;let f=m?80:16,p=55+(e.Be?16:0),d=Math.max(1,s-p-f),b=e.rt?Mt(e.rt):void 0,x=e.it?We(e.it,d):void 0,h=new ne(s,a,{hasXLabel:!!e.Ue,hasYLabel:!!e.Be,hasLegend:m,leftExtra:b,bottomExtra:x});e.l=h,e.g&&e.g.updateLayout(h);let g=h.buildProjectionMatrix(n.xMin,n.xMax,n.yMin,n.yMax,void 0,void 0,void 0,Xe(e.w),Xe(e.M)),y=Co(e,n.xMin,n.xMax,l),_=_o(e,n.yMin,n.yMax,u),C=Rt(y,_,h),v=e.Pe?[]:C.xTicks,A=e.ge?[]:C.yTicks,T=e.Cn===\"map\",L=t.dpr,R=e.j;R&&!T?e.pe(()=>{ue(R,h,L),Oi(R,h,v,A,o,L)}):R&&T&&e.pe(()=>ue(R,h,L)),ze(r,h,t.dpr,()=>{T&&e.renderBackground(t,h,g,n,Xe(e.w),Xe(e.M)),e.glyph.draw(e,t,g)}),e.he=y,e.xe=_,e.co=v,e.Re=A,e.po=o.H,e.bo=m}function Qu(e,t,n,o,i){let r=t.gl,{cssWidth:s,cssHeight:a,xIsDate:l,yIsDate:u}=i;e.it=e.Pe&&e.Kt.length>0?vo(e.Kt,e.Ue||e.$e||\"\"):null,e.rt=e.ge&&e.Jt.length>0?vo(e.Jt,e.Be||e.Oe||\"\"):null;let m=e.L.map(L=>L.prefix),f=e.Z&&e.f.size>1,p=!!e.a&&!e.Z&&e.b<e.p,d=f||p,b=Re(m,{cssWidth:s,cssHeight:a,xAxis:e.eo?\"outer\":\"cell\",yAxis:e.to?\"outer\":\"cell\",hasLegend:d,hasXLabel:!!e.Ue,hasYLabel:!!e.Be,gap:e.G.facet_padding});if(e.m=b,b.cells.length>1){let L=b.cells[0].layout.e;for(let R=1;R<b.cells.length;R++){let F=b.cells[R].layout.e;if(F.width!==L.width||F.height!==L.height){console.warn(`facet-grid: cell ${R} size (${F.width}\\xD7${F.height}) differs from cell 0 (${L.width}\\xD7${L.height})`);break}}}e.l=b.cells[0]?.layout??null,e.syncFacetZoomLayouts(b.cells);let x=e.G.zoom_mode===\"independent\",h=Co(e,n.xMin,n.xMax,l),g=_o(e,n.yMin,n.yMax,u),y=b.cells[0]?.layout,_=y?Rt(h,g,y):{xTicks:[],yTicks:[]},C=e.Pe?[]:_.xTicks,v=e.ge?[]:_.yTicks,A=t.dpr,T=e.j;T&&y&&e.pe(()=>ue(T,y,A)),at(r);for(let L=0;L<b.cells.length;L++){let R=b.cells[L],F=e.getZoomControllerForFacet(L),I=x&&F?F.getVisibleDomain():n,S=R.layout.buildProjectionMatrix(I.xMin,I.xMax,I.yMin,I.yMax,void 0,void 0,void 0,Xe(e.w),Xe(e.M)),D=e.Cn===\"map\";T&&!D&&e.pe(()=>{let B=x?Rt(Co(e,I.xMin,I.xMax,l),_o(e,I.yMin,I.yMax,u),R.layout).xTicks:C,N=x?Rt(Co(e,I.xMin,I.xMax,l),_o(e,I.yMin,I.yMax,u),R.layout).yTicks:v;Oi(T,R.layout,B,N,o,A)}),lt(r,R.layout,t.dpr,()=>{D&&e.renderBackground(t,R.layout,S,I,Xe(e.w),Xe(e.M)),e.glyph.drawSeries(e,t,S,L)})}e.he=h,e.xe=g,e.co=C,e.Re=v,e.po=o.H,e.bo=d}function $e(e){!e.c||!e.l||!e.he||!e.xe||!e.t||(ue(e.c,e.l,e.t.dpr),e.m?tm(e):em(e))}function em(e){let t=e.l,n=e.A(),o=e.t?.dpr??1;if(e.Cn===\"map\"?e.renderMapChrome(e.c,t,n,o):Ku(e,e.c,t,e.he,e.xe,e.co,e.Re,n,o),e.bo){let r=e.po??n.H;if(e.Z&&e.f.size>0){let s=de(n.ke,r,e.f.size);xo(e.c,t,e.f,s,n)}else e.a&&St(e.c,t,{min:e.b,max:e.p,label:e.a},r,n,e.getColumnFormatter(e.a,\"value\"))}Xs(e,e.c,t,0,1),e.ae>=0&&e.O&&e.V&&im(e,e.c,t)}function tm(e){let t=e.m,n=e.c,o=e.A(),i=e.t?.dpr??1,r=e.co,s=e.Re,a=e.he,l=e.xe,u=e.Cn===\"map\",m=e.eo&&!e.Pe,f=e.to&&!e.ge,p=e.G.zoom_mode===\"independent\";u&&e.renderMapChrome(n,e.l,o,i),!u&&m&&t.outerXAxisRect&&sn(n,t.outerXAxisRect,a,r,en(t),o,!!e.Ue,i,e.getColumnFormatter(e.$e,\"tick\")),!u&&f&&t.outerYAxisRect&&an(n,t.outerYAxisRect,l,s,tn(t),o,!!e.Be,i,e.getColumnFormatter(e.Oe,\"tick\"));for(let d=0;d<t.cells.length;d++){let b=t.cells[d],x=p?e.getZoomControllerForFacet(d):null,h=x?x.getVisibleDomain():null,g=h?{...a,min:h.xMin,max:h.xMax}:a,y=h?{...l,min:h.yMin,max:h.yMax}:l,_=p?Rt(g,y,b.layout):{xTicks:r,yTicks:s};if(!u&&!m)if(e.Pe&&e.it){let C=re(n,i);C&&pe(C,b.layout,e.it,o)}else Vi(n,g,b.layout,_.xTicks,o,!!e.Ue,i,e.getColumnFormatter(e.$e,\"tick\"));if(!u&&!f)if(e.ge&&e.rt){let C=re(n,i);C&&we(C,b.layout,e.rt,o)}else Hi(n,y,b.layout,_.yTicks,o,!!e.Be,i,e.getColumnFormatter(e.Oe,\"tick\"));b.titleRect&&_t(n,b.label,b.titleRect,o,i),Xs(e,n,b.layout,d,d+1)}if(e.bo&&t.legendRect){let d=e.po??o.H;if(e.Z&&e.f.size>0){let b=de(o.ke,d,Math.max(1,e.f.size));fn(n,t.legendRect,e.f,b,o)}else e.a&&mn(n,{x:t.legendRect.x,y:t.legendRect.y+20,width:t.legendRect.width,height:t.legendRect.height-20},{min:e.b,max:e.p,label:e.a},d,o,e.getColumnFormatter(e.a,\"value\"))}if(e.ae>=0&&e.O&&e.V){let d=isNaN(e.w)?0:e.w,b=isNaN(e.M)?0:e.M,x=e.O[e.ae]+d,h=e.V[e.ae]+b,g=nm(e,e.ae),y=e.glyph.tooltipOptions(),_=e.W.lines??[];for(let C=0;C<t.cells.length;C++){let v=t.cells[C],A=C===g,T=v.layout.P(x,h),L=v.layout.e;if(T.px<L.x||T.px>L.x+L.width||T.py<L.y||T.py>L.y+L.height)continue;let R=e.G.coordinated_tooltip;Pe(n,T,A||R?_:[],v.layout,o,i,{crosshair:y.crosshair,highlightRadius:A?y.highlightRadius:0})}}}function nm(e,t){return e.R<=0?0:Math.floor(t/e.R)}function Xs(e,t,n,o,i){if(!e.Et||!e.O||!e.V)return;let r=e.Et.dictionary,s=e.Et.data,a=e.O,l=e.V,u=isNaN(e.w)?0:e.w,m=isNaN(e.M)?0:e.M,f=e.R;if(f<=0)return;let p=0;for(let y=o;y<i;y++)p+=e.U[y]??0;if(p===0)return;let d=e.t?.dpr??1,b=re(t,d);if(!b)return;let x=e.A(),h=n.e,g=Math.max(1,Math.ceil(p/om));b.save(),b.font=`11px ${x.fontFamily}`,b.fillStyle=x.Le,b.textAlign=\"left\",b.textBaseline=\"middle\";for(let y=o;y<i;y++){let _=e.U[y]??0,C=y*f;for(let v=0;v<_;v+=g){let A=C+v,T=s[A];if(T<0)continue;let{px:L,py:R}=n.P(a[A]+u,l[A]+m);L<h.x||L>h.x+h.width||R<h.y||R>h.y+h.height||b.fillText(r[T],L+8,R-4)}}b.restore()}function im(e,t,n){let o=e.ae;if(o<0||!e.O||!e.V)return;let i=isNaN(e.w)?0:e.w,r=isNaN(e.M)?0:e.M,s=n.P(e.O[o]+i,e.V[o]+r),a=e.W.lines??[],l=e.A();Pe(t,s,a,n,l,e.t?.dpr??1,e.glyph.tooltipOptions())}var om,Ki=G(()=>{\"use strict\";mo();Ye();vt();nn();Ee();on();At();Ct();Yi();ut();Ft();yo();om=5e3});function rm(e){if(!e.qt.isDirty||!e.O||!e.V)return;let t=e.O,n=e.V,o=Math.max(1,e.L.length),i=e.R,r=isNaN(e.w)?0:e.w,s=isNaN(e.M)?0:e.M;e.qt.rebuild({xMin:e.be-r,xMax:e.et-r,yMin:e.Te-s,yMax:e.tt-s},e.xt,a=>{for(let l=0;l<o;l++){let u=e.U[l]??0,m=l*i;for(let f=0;f<u;f++)a(m+f,t[m+f],n[m+f])}})}function Ji(e,t,n){if(!e.O||!e.V)return;let{layout:o,facetIdx:i}=sm(e,t,n);if(!o){$s(e);return}let r=o.e;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){$s(e);return}let s=o.Y,a=o.J,l=o.q,u=o.Q,m=s+(t-r.x)/r.width*(a-s),f=u-(n-r.y)/r.height*(u-l),p=r.width/(a-s),d=r.height/(u-l),b=isNaN(e.w)?0:e.w,x=isNaN(e.M)?0:e.M,h=m-b,g=f-x,y=i<0?am(e,h,g,p,d):lm(e,i,h,g,p,d);if(y!==e.ae||i!==e._n){if(e.ae=y,e._n=i,y>=0){let _=e.W.beginHover(y);e.glyph.buildTooltipLines(e,y).then(C=>{e.W.commitHover(_,C)&&$e(e)})}else e.W.clearHover();$e(e)}}function $s(e){(e.ae!==-1||e._n!==-1)&&(e.ae=-1,e._n=-1,$e(e))}function sm(e,t,n){if(e.m){let o=e.m.cells;for(let i=0;i<o.length;i++){let r=o[i].layout.e;if(t>=r.x&&t<=r.x+r.width&&n>=r.y&&n<=r.y+r.height)return{layout:o[i].layout,facetIdx:i}}return{layout:null,facetIdx:-1}}return{layout:e.l,facetIdx:-1}}function am(e,t,n,o,i){rm(e);let r=e.qt.query(t,n,cn,o,i,e.O,e.V);if(r>=0)return r;let s=cn*cn,a=Math.max(1,e.L.length),l=e.R,u=e.O,m=e.V;for(let f=0;f<a;f++){let p=e.U[f]??0,d=f*l;for(let b=0;b<p;b++){let x=d+b,h=(u[x]-t)*o,g=(m[x]-n)*i,y=h*h+g*g;y<s&&(s=y,r=x)}}return r}function lm(e,t,n,o,i,r){let s=e.U[t]??0;if(s===0)return-1;let a=e.R,l=t*a,u=e.O,m=e.V,f=cn*cn,p=-1;for(let d=0;d<s;d++){let b=l+d,x=(u[b]-n)*i,h=(m[b]-o)*r,g=x*x+h*h;g<f&&(f=g,p=b)}return p}function js(e,t){if(e.T.dismiss(),e.qo=t,t<0||!e.O||!e.V)return;let n=um(e,t);if(!n)return;let o=isNaN(e.w)?0:e.w,i=isNaN(e.M)?0:e.M,r=n.P(e.O[t]+o,e.V[t]+i),s=e.W.beginPin();e.glyph.buildTooltipLines(e,t).then(a=>{e.W.isPinFresh(s)&&e.qo===t&&a.length!==0&&e.T.pin(a,r,n)}),e.ae=-1,e._n=-1,$e(e)}function um(e,t){if(e.m&&e.R>0){let n=Math.floor(t/e.R),o=e.m.cells[n];if(o)return o.layout}return e.l}function Zs(e){e.T.dismiss(),e.qo=-1}var cn,qs=G(()=>{\"use strict\";Ki();cn=24});var It,Qi=G(()=>{\"use strict\";It=class{constructor(){c(this,\"lines\",null);c(this,\"hoveredTarget\",null);c(this,\"Ko\",0);c(this,\"Jo\",0)}beginHover(t){return this.lines=null,this.hoveredTarget=t,++this.Ko}commitHover(t,n){return t!==this.Ko?!1:(this.lines=n,!0)}clearHover(){this.lines=null,this.hoveredTarget=null,this.Ko++}beginPin(){return++this.Jo}isPinFresh(t){return t===this.Jo}invalidatePin(){this.Jo++}}});function j(e,t,n,o,i,r){let s=e.shaders.getOrCreate(t,n,o),a=e.gl,l={program:s};for(let u of i)l[u]=a.getUniformLocation(s,u);for(let u of r)l[u]=a.getAttribLocation(s,u);return l}var fe=G(()=>{\"use strict\"});async function Ao(e,t){let n=[];if(!e.Pt||!e.De)return n;let o=e.Pt[t];if(o<0)return n;if(e.L.length>0&&e.R>0){let s=Math.floor(t/e.R),a=e.L[s];a?.prefix&&n.push(a.prefix)}let i=await e.De.fetchRow(o),r=e.L.length>0&&e.R>0?e.L[Math.floor(t/e.R)]?.prefix??null:null;for(let[s,a]of i){if(a==null)continue;let l=s;if(r!==null){let u=`${r}|`;if(!s.startsWith(u))continue;l=s.substring(u.length)}else if(s.includes(\"|\"))continue;if(typeof a==\"number\"){let u=e.getColumnFormatter(s,\"value\")(a);n.push(`${l}: ${u}`)}else n.push(`${l}: ${a}`)}return n}var er=G(()=>{\"use strict\"});function mm(e,t,n,o,i){t.uniformMatrix4fv(e.u_projection,!1,n),t.uniform1f(e.u_point_size,o.h.point_size_px*i),o.b<o.p?t.uniform2f(e.u_color_range,o.b,o.p):t.uniform2f(e.u_color_range,0,0),o.nt<o.ot?t.uniform2f(e.u_size_range,o.nt,o.ot):t.uniform2f(e.u_size_range,0,0);let r=Math.min(o.h.point_size_px,3);t.uniform2f(e.u_point_size_range,Math.max(2*i,o.h.point_size_px/r*i),o.h.point_size_px*r*i)}function Ks(e,t,n,o){let i=n.gl;if(!t.oe)return!1;i.useProgram(e.program),mm(e,i,o,t,n.dpr),Ge(n,t.oe.texture,e.u_gradient_lut,0);let r=n.v.peek(\"a_position\"),s=n.v.peek(\"a_color_value\"),a=n.v.peek(\"a_size_value\");return!r||!s||!a?!1:(i.bindBuffer(i.ARRAY_BUFFER,r.buffer),i.enableVertexAttribArray(e.a_position),i.vertexAttribPointer(e.a_position,2,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,s.buffer),i.enableVertexAttribArray(e.a_color_value),i.vertexAttribPointer(e.a_color_value,1,i.FLOAT,!1,0,0),i.bindBuffer(i.ARRAY_BUFFER,a.buffer),i.enableVertexAttribArray(e.a_size_value),i.vertexAttribPointer(e.a_size_value,1,i.FLOAT,!1,0,0),!0)}var Dt,tr=G(()=>{\"use strict\";At();fe();er();Ri();wi();Dt=class{constructor(){c(this,\"name\",\"point\");c(this,\"d\",null)}ensureProgram(t,n){this.d||(this.d=j(n,\"scatter\",Bn,Pn,[\"u_projection\",\"u_point_size\",\"u_color_range\",\"u_gradient_lut\",\"u_size_range\",\"u_point_size_range\"],[\"a_position\",\"a_color_value\",\"a_size_value\"]))}draw(t,n,o){let i=this.d;if(!i||!Ks(i,t,n,o))return;let r=n.gl,s=Math.max(1,t.L.length),a=t.R;for(let l=0;l<s;l++){let u=t.U[l]??0;u<=0||r.drawArrays(r.POINTS,l*a,u)}}drawSeries(t,n,o,i){let r=this.d;if(!r||!Ks(r,t,n,o))return;let s=t.U[i]??0;if(s<=0)return;let a=n.gl,l=t.R;a.drawArrays(a.POINTS,i*l,s)}buildTooltipLines(t,n){return Ao(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:6}}destroy(t){this.d=null}}});function J(e){let t=e.gl;if(e.isWebGL2){let o=t;return{setDivisor(i,r){i<0||o.vertexAttribDivisor(i,r)},drawArraysInstanced(i,r,s,a){o.drawArraysInstanced(i,r,s,a)}}}let n=t.getExtension(\"ANGLE_instanced_arrays\");return{setDivisor(o,i){o<0||n?.vertexAttribDivisorANGLE(o,i)},drawArraysInstanced(o,i,r,s){n?.drawArraysInstancedANGLE(o,i,r,s)}}}function je(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,1,2,3]),e.STATIC_DRAW),t}function Lo(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),t}function Ze(e,t,n,o,i,r=0){if(n<0)return!0;let s=e.v.peek(o);if(!s)return!1;let a=e.gl;return a.bindBuffer(a.ARRAY_BUFFER,s.buffer),a.enableVertexAttribArray(n),a.vertexAttribPointer(n,i,a.FLOAT,!1,0,r*i*Float32Array.BYTES_PER_ELEMENT),t.setDivisor(n,1),!0}var Me=G(()=>{\"use strict\"});function Js(e,t,n,o){let i=n.gl;if(!t.oe)return!1;let r=n.dpr;i.useProgram(e.program),i.uniformMatrix4fv(e.u_projection,!1,o),i.uniform2f(e.u_resolution,i.canvas.width,i.canvas.height),i.uniform1f(e.u_line_width,t.h.line_width_px*r),t.b<t.p?i.uniform2f(e.u_color_range,t.b,t.p):i.uniform2f(e.u_color_range,0,0),Ge(n,t.oe.texture,e.u_gradient_lut,0);let s=J(n),{setDivisor:a}=s;return i.bindBuffer(i.ARRAY_BUFFER,e.cornerBuffer),i.enableVertexAttribArray(e.a_corner),i.vertexAttribPointer(e.a_corner,1,i.FLOAT,!1,0,0),a(e.a_corner,0),i.enableVertexAttribArray(e.a_start),a(e.a_start,1),i.enableVertexAttribArray(e.a_end),a(e.a_end,1),i.enableVertexAttribArray(e.a_color_start),a(e.a_color_start,1),i.enableVertexAttribArray(e.a_color_end),a(e.a_color_end,1),!0}function Qs(e,t,n,o){let i=t.U[o]??0;if(i<2)return;let r=n.gl,s=t.R,a=2*Float32Array.BYTES_PER_ELEMENT,l=Float32Array.BYTES_PER_ELEMENT,u=n.v.peek(\"a_position\"),m=n.v.peek(\"a_color_value\");if(!u||!m)return;let f=o*s*a;r.bindBuffer(r.ARRAY_BUFFER,u.buffer),r.vertexAttribPointer(e.a_start,2,r.FLOAT,!1,a,f),r.vertexAttribPointer(e.a_end,2,r.FLOAT,!1,a,f+a);let p=o*s*l;r.bindBuffer(r.ARRAY_BUFFER,m.buffer),r.vertexAttribPointer(e.a_color_start,1,r.FLOAT,!1,l,p),r.vertexAttribPointer(e.a_color_end,1,r.FLOAT,!1,l,p+l),J(n).drawArraysInstanced(r.TRIANGLE_STRIP,0,4,i-1)}function ea(e,t){let{setDivisor:n}=J(t);n(e.a_start,0),n(e.a_end,0),n(e.a_color_start,0),n(e.a_color_end,0)}var Bt,nr=G(()=>{\"use strict\";At();Me();fe();Ae();Li();Ti();Bt=class{constructor(){c(this,\"name\",\"line\");c(this,\"d\",null)}ensureProgram(t,n){if(this.d)return;let o=j(n,\"line\",In,Dn,[\"u_projection\",\"u_resolution\",\"u_line_width\",\"u_color_range\",\"u_gradient_lut\"],[\"a_start\",\"a_end\",\"a_color_start\",\"a_color_end\",\"a_corner\"]);this.d={...o,cornerBuffer:je(n.gl)}}draw(t,n,o){let i=this.d;if(!i||!Js(i,t,n,o))return;let s=Math.max(1,t.L.length);for(let a=0;a<s;a++)Qs(i,t,n,a);ea(i,n)}drawSeries(t,n,o,i){let r=this.d;r&&Js(r,t,n,o)&&(Qs(r,t,n,i),ea(r,n))}async buildTooltipLines(t,n){let o=[];if(!t.O||!t.V)return o;if(t.L.length>0&&t.R>0){let p=Math.floor(n/t.R),d=t.L[p];d&&o.push(d.prefix)}let i=t.O[n],r=t.V[n],s=t.Ne[t.Ue]||\"\",l=s===\"date\"||s===\"datetime\"?ye(i):me(i);o.push(`${t.Ue||\"Row\"}: ${l}`);let u=t.Ne[t.Be]||\"\",f=u===\"date\"||u===\"datetime\"?ye(r):me(r);return o.push(`${t.Be}: ${f}`),o}tooltipOptions(){return{crosshair:!0,highlightRadius:5}}destroy(t){let n=this.d;n?.cornerBuffer&&t.t&&t.t.gl.deleteBuffer(n.cornerBuffer),this.d=null}}});function bm(e){switch(e){case\"density\":return fm;case\"extreme\":return dm;case\"signed\":return pm;case\"mean\":default:return cm}}function ta(e){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function or(e,t,n,o){return j(e,t,n,o,[\"u_projection\",\"u_radius_ndc\",\"u_intensity\",\"u_color_range\"],[\"a_corner\",\"a_position\",\"a_color_value\"])}function gm(e){let t=e.gl;if(e.isWebGL2){let n=t;if(n.getExtension(\"EXT_color_buffer_float\"))return{internalFormat:n.RGBA16F,format:n.RGBA,type:n.HALF_FLOAT,isFloat:!0}}return{internalFormat:t.RGBA,format:t.RGBA,type:t.UNSIGNED_BYTE,isFloat:!1}}function na(e){let t=e.v.peek(\"a_position\"),n=e.v.peek(\"a_color_value\");return!!t&&!!n}function xm(e,t){if(!e.a||e.Z)return t.robustBounds=null,null;let n=t.robustBounds;if(n&&n.dataCount===e.xt&&n.colorName===e.a&&n.colorIsString===e.Z)return{lo:n.lo,hi:n.hi};let o=ym(e);return o?(t.robustBounds={lo:o.lo,hi:o.hi,dataCount:e.xt,colorName:e.a,colorIsString:e.Z},o):(t.robustBounds=null,null)}function ym(e){if(!e.yt||e.xt<2)return null;let t=e.R,n=Math.max(1,e.L.length),o=Math.max(1,Math.ceil(e.xt/hm)),i=[],r=e.yt;for(let m=0;m<n;m++){let f=e.U[m]??0,p=m*t;for(let d=0;d<f;d+=o){let b=r[p+d];Number.isFinite(b)&&i.push(b)}}if(i.length<2)return null;i.sort((m,f)=>m-f);let s=Math.floor(i.length*.05),a=Math.min(i.length-1,Math.ceil(i.length*.95)),l=i[s],u=i[a];return u>l?{lo:l,hi:u}:e.p>e.b?{lo:e.b,hi:e.p}:null}var fm,cm,dm,pm,Pt,hm,ir=G(()=>{\"use strict\";At();Me();fe();er();Mi();Fi();Si();Zr();Kr();Ii();Di();fm=0,cm=1,dm=2,pm=3,Pt=class{constructor(){c(this,\"name\",\"density\");c(this,\"d\",null)}ensureProgram(t,n){if(this.d){this.ensureHeatTarget(t,n);return}let o=n.gl,i=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,i),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),o.STATIC_DRAW);let r=o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,r),o.bufferData(o.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),o.STATIC_DRAW);let{internalFormat:s,format:a,type:l,isFloat:u}=gm(n),m=ta(o),f=o.createFramebuffer();this.d={splat:or(n,\"density-splat\",xt,$n),extremeSplat:null,mrtSplat:null,resolve:j(n,\"density-resolve\",Zn,qn,[\"u_heat\",\"u_extreme\",\"u_gradient_lut\",\"u_heat_max\",\"u_color_mode\"],[\"a_corner\"]),quadCornerBuffer:i,tripleCornerBuffer:r,heatTexture:m,heatFramebuffer:f,extremeTexture:null,extremeFramebuffer:null,mrtFramebuffer:null,heatWidth:0,heatHeight:0,heatType:l,heatInternalFormat:s,heatFormat:a,floatFbo:u,indexedBlend:null,signedDowngradeWarned:!1,robustBounds:null},this.ensureHeatTarget(t,n)}draw(t,n,o){let i=this.d;if(!i||!na(n))return;let r=Math.max(1,t.L.length),s=t.R,a=0;for(let l=0;l<r;l++)a+=t.U[l]??0;a!==0&&this.runSplatAndResolve(t,n,i,o,l=>{for(let u=0;u<r;u++){let m=t.U[u]??0;m<=0||l(u*s,m)}})}drawSeries(t,n,o,i){let r=this.d;if(!r||!na(n))return;let s=t.U[i]??0;if(s<=0)return;let a=t.R;this.runSplatAndResolve(t,n,r,o,l=>l(i*a,s))}buildTooltipLines(t,n){return Ao(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:0}}destroy(t){let n=this.d;if(!n||!t.t){this.d=null;return}let o=t.t.gl;o.deleteBuffer(n.quadCornerBuffer),o.deleteBuffer(n.tripleCornerBuffer),o.deleteTexture(n.heatTexture),o.deleteFramebuffer(n.heatFramebuffer),n.extremeTexture&&o.deleteTexture(n.extremeTexture),n.extremeFramebuffer&&o.deleteFramebuffer(n.extremeFramebuffer),n.mrtFramebuffer&&o.deleteFramebuffer(n.mrtFramebuffer),this.d=null}ensureHeatTarget(t,n){let o=this.d;if(!o)return;let i=n.gl,r=i.canvas.width,s=i.canvas.height;if(!(r===o.heatWidth&&s===o.heatHeight)&&!(r<=0||s<=0)){if(this.allocAccumTexture(i,o,o.heatTexture,r,s),i.bindFramebuffer(i.FRAMEBUFFER,o.heatFramebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.heatTexture,0),o.extremeTexture&&(this.allocAccumTexture(i,o,o.extremeTexture,r,s),o.extremeFramebuffer&&(i.bindFramebuffer(i.FRAMEBUFFER,o.extremeFramebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o.extremeTexture,0)),o.mrtFramebuffer)){let a=i;a.bindFramebuffer(a.FRAMEBUFFER,o.mrtFramebuffer),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,o.heatTexture,0),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT1,a.TEXTURE_2D,o.extremeTexture,0)}i.bindFramebuffer(i.FRAMEBUFFER,null),o.heatWidth=r,o.heatHeight=s}}allocAccumTexture(t,n,o,i,r){t.bindTexture(t.TEXTURE_2D,o),t.texImage2D(t.TEXTURE_2D,0,n.heatInternalFormat,i,r,0,n.heatFormat,n.heatType,null)}ensureExtremeTarget(t,n){let o=t.gl;if(n.extremeTexture)return;let i=ta(o);if(n.extremeTexture=i,n.extremeFramebuffer=o.createFramebuffer(),this.allocAccumTexture(o,n,i,n.heatWidth,n.heatHeight),o.bindFramebuffer(o.FRAMEBUFFER,n.extremeFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i,0),n.indexedBlend===null){let r=t.isWebGL2?o.getExtension(\"OES_draw_buffers_indexed\"):null;n.indexedBlend=r??!1}if(n.indexedBlend){let r=o;n.mrtFramebuffer=r.createFramebuffer(),r.bindFramebuffer(r.FRAMEBUFFER,n.mrtFramebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,n.heatTexture,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT1,r.TEXTURE_2D,i,0)}o.bindFramebuffer(o.FRAMEBUFFER,null)}ensureExtremeSplatProgram(t,n){return n.extremeSplat||(n.extremeSplat=or(t,\"density-extreme\",xt,jn)),n.extremeSplat}ensureMrtSplatProgram(t,n){return n.mrtSplat||(n.mrtSplat=or(t,\"density-mrt\",qr,Jr)),n.mrtSplat}activeMode(t,n,o){let i=n.h.gradient_color_mode;return i===\"signed\"&&!o.floatFbo?(this.warnDowngradeOnce(o,\"signed mode requires a float framebuffer (EXT_color_buffer_float); falling back to mean.\"),\"mean\"):i===\"extreme\"&&!t.isWebGL2?(this.warnDowngradeOnce(o,\"extreme mode requires WebGL2 (for MAX blend and a second color attachment); falling back to mean.\"),\"mean\"):i}warnDowngradeOnce(t,n){t.signedDowngradeWarned||(t.signedDowngradeWarned=!0,console.warn(`Density: ${n}`))}runSplatAndResolve(t,n,o,i,r){if(this.ensureHeatTarget(t,n),o.heatWidth===0||o.heatHeight===0||!t.oe)return;let s=this.activeMode(n,t,o),a=t.b<t.p&&(!!t.a||t.L.length>1),l=0,u=0;if(s!==\"density\"&&a&&(l=t.b,u=t.p,!t.Z&&(s===\"mean\"||s===\"extreme\"))){let f=xm(t,o);f&&(l=f.lo,u=f.hi)}s===\"extreme\"&&this.ensureExtremeTarget(n,o),s===\"extreme\"&&o.indexedBlend?this.runMrtExtremePass(n,o,i,t.h.gradient_intensity,n.dpr*t.h.gradient_radius_px,l,u,r):(this.runHeatPass(n,o,i,t.h.gradient_intensity,n.dpr*t.h.gradient_radius_px,l,u,r),s===\"extreme\"&&this.runExtremePass(n,o,i,t.h.gradient_intensity,n.dpr*t.h.gradient_radius_px,l,u,r)),this.runResolvePass(n,o,t,s)}runHeatPass(t,n,o,i,r,s,a,l){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST);u.bindFramebuffer(u.FRAMEBUFFER,n.heatFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE),u.blendEquation(u.FUNC_ADD),this.bindSplatProgram(u,n.splat,o,i,r,n.heatWidth,n.heatHeight,s,a),this.bindAndDispatchInstanced(t,n,n.splat,l),this.unbindSplatInstancing(t,n.splat)}runExtremePass(t,n,o,i,r,s,a,l){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST),f=this.ensureExtremeSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.extremeFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE);let p=u;p.blendEquation(p.MAX),this.bindSplatProgram(u,f,o,i,r,n.heatWidth,n.heatHeight,s,a),this.bindAndDispatchInstanced(t,n,f,l),this.unbindSplatInstancing(t,f),u.blendEquation(u.FUNC_ADD)}runMrtExtremePass(t,n,o,i,r,s,a,l){let u=t.gl,m=n.indexedBlend,f=!!u.getParameter(u.SCISSOR_TEST),p=this.ensureMrtSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.mrtFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),u.drawBuffers([u.COLOR_ATTACHMENT0,u.COLOR_ATTACHMENT1]),this.clearTarget(u,f),m.enableiOES(u.BLEND,0),m.enableiOES(u.BLEND,1),m.blendEquationiOES(0,u.FUNC_ADD),m.blendFunciOES(0,u.ONE,u.ONE),m.blendEquationiOES(1,u.MAX),m.blendFunciOES(1,u.ONE,u.ONE),this.bindSplatProgram(u,p,o,i,r,n.heatWidth,n.heatHeight,s,a),this.bindAndDispatchInstanced(t,n,p,l),this.unbindSplatInstancing(t,p),m.blendEquationiOES(0,u.FUNC_ADD),m.blendEquationiOES(1,u.FUNC_ADD),m.blendFunciOES(0,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),m.blendFunciOES(1,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawBuffers([u.COLOR_ATTACHMENT0])}clearTarget(t,n){n&&t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),n&&t.enable(t.SCISSOR_TEST)}bindSplatProgram(t,n,o,i,r,s,a,l,u){t.useProgram(n.program),t.uniformMatrix4fv(n.u_projection,!1,o),t.uniform1f(n.u_intensity,i);let m=2*r/Math.max(1,s),f=2*r/Math.max(1,a);t.uniform2f(n.u_radius_ndc,m,f),t.uniform2f(n.u_color_range,l,u)}bindAndDispatchInstanced(t,n,o,i){let r=t.gl;r.bindBuffer(r.ARRAY_BUFFER,n.quadCornerBuffer),r.enableVertexAttribArray(o.a_corner),r.vertexAttribPointer(o.a_corner,2,r.FLOAT,!1,0,0);let s=J(t);s.setDivisor(o.a_corner,0),s.setDivisor(o.a_position,1),s.setDivisor(o.a_color_value,1);let a=t.v.peek(\"a_position\"),l=t.v.peek(\"a_color_value\");i((u,m)=>{let f=2*Float32Array.BYTES_PER_ELEMENT,p=Float32Array.BYTES_PER_ELEMENT;r.bindBuffer(r.ARRAY_BUFFER,a.buffer),r.enableVertexAttribArray(o.a_position),r.vertexAttribPointer(o.a_position,2,r.FLOAT,!1,f,u*f),r.bindBuffer(r.ARRAY_BUFFER,l.buffer),r.enableVertexAttribArray(o.a_color_value),r.vertexAttribPointer(o.a_color_value,1,r.FLOAT,!1,p,u*p),s.drawArraysInstanced(r.TRIANGLE_STRIP,0,4,m)})}unbindSplatInstancing(t,n){let o=J(t);o.setDivisor(n.a_position,0),o.setDivisor(n.a_color_value,0)}runResolvePass(t,n,o,i){let r=t.gl;r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,r.canvas.width,r.canvas.height),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA);let s=n.resolve;r.useProgram(s.program),r.uniform1f(s.u_heat_max,o.h.gradient_heat_max),r.uniform1i(s.u_color_mode,bm(i)),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.heatTexture),r.uniform1i(s.u_heat,0),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,n.extremeTexture??n.heatTexture),r.uniform1i(s.u_extreme,1),Ge(t,o.oe.texture,s.u_gradient_lut,2),r.bindBuffer(r.ARRAY_BUFFER,n.tripleCornerBuffer),r.enableVertexAttribArray(s.a_corner),r.vertexAttribPointer(s.a_corner,2,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLES,0,3)}};hm=5e4});var ft,To,Ro,wo,rr=G(()=>{\"use strict\";Jt();Rs();Is();Ki();qs();Qi();tr();nr();ir();ft=class extends Te{constructor(n){super();c(this,\"glyph\");c(this,\"Cn\",\"cartesian\");c(this,\"oe\",null);c(this,\"$e\",\"\");c(this,\"Oe\",\"\");c(this,\"Ue\",\"\");c(this,\"Be\",\"\");c(this,\"Ei\",!1);c(this,\"a\",\"\");c(this,\"ne\",\"\");c(this,\"mo\",\"\");c(this,\"Z\",!1);c(this,\"Pe\",!1);c(this,\"ge\",!1);c(this,\"Kt\",[]);c(this,\"Jt\",[]);c(this,\"Gi\",new Map);c(this,\"Wi\",new Map);c(this,\"it\",null);c(this,\"rt\",null);c(this,\"L\",[]);c(this,\"be\",1/0);c(this,\"et\",-1/0);c(this,\"Te\",1/0);c(this,\"tt\",-1/0);c(this,\"w\",NaN);c(this,\"M\",NaN);c(this,\"b\",1/0);c(this,\"p\",-1/0);c(this,\"nt\",1/0);c(this,\"ot\",-1/0);c(this,\"gn\",1/0);c(this,\"hn\",-1/0);c(this,\"xn\",1/0);c(this,\"yn\",-1/0);c(this,\"ro\",1/0);c(this,\"so\",-1/0);c(this,\"ao\",1/0);c(this,\"uo\",-1/0);c(this,\"R\",0);c(this,\"U\",[]);c(this,\"Yo\",0);c(this,\"O\",null);c(this,\"V\",null);c(this,\"yt\",null);c(this,\"Pt\",null);c(this,\"Et\",null);c(this,\"xt\",0);c(this,\"f\",new Map);c(this,\"W\",new It);c(this,\"zo\",null);c(this,\"Xo\",null);c(this,\"$o\",null);c(this,\"ki\",0);c(this,\"qt\",new lo);c(this,\"l\",null);c(this,\"ae\",-1);c(this,\"qo\",-1);c(this,\"_n\",-1);c(this,\"m\",null);c(this,\"he\",null);c(this,\"xe\",null);c(this,\"co\",null);c(this,\"Re\",null);c(this,\"po\",null);c(this,\"bo\",!1);c(this,\"fo\",null);c(this,\"jo\",null);c(this,\"Zo\",-1);this.glyph=n}projectPoint(n,o){return[n,o]}renderBackground(n,o,i,r,s,a){}renderMapChrome(n,o,i,r){}tooltipCallbacks(){return{onHover:(n,o)=>Ji(this,n,o),onLeave:()=>{this.ae!==-1&&(this.ae=-1,$e(this))},onPin:(n,o)=>{if(Ji(this,n,o),this.ae>=0){let i=this.ae;js(this,i),this.ir(i)}},onUnpin:()=>{this.emitUnselect()}}}async ir(n){if(!this.Pt)return;let o=this.Pt[n],i=this.I[1]||this.I[0]||\"\",r=[];if(this.L.length>0&&this.R>0){let s=Math.floor(n/this.R),a=this.L[s];a?.prefix&&this.B.length>0&&(r=a.prefix.split(\"|\"))}await this.emitClickAndSelect({rowIdx:o!=null&&o>=0?o:null,columnName:i,groupByValues:[],splitByValues:r})}async uploadAndRender(n,o,i,r){let s=r-i;this.t=n,i===0&&Fs(this,n,o,r),s!==0&&(Ss(this,n,o,i,s,r),this.h.domain_mode===\"expand\"&&(this.Pe||(this.gn=this.be,this.hn=this.et),this.ge||(this.xn=this.Te,this.yn=this.tt),this.ro=this.b,this.so=this.p,this.ao=this.nt,this.uo=this.ot),await this.requestRender(n))}resetExpandedDomain(){this.gn=1/0,this.hn=-1/0,this.xn=1/0,this.yn=-1/0,this.ro=1/0,this.so=-1/0,this.ao=1/0,this.uo=-1/0}Dt(n){n.uploadedCount===0&&this.xt===0||(this.t=n,zs(this,n))}destroyInternal(){this.glyph.destroy(this),this.oe=null,this.O=null,this.V=null,this.yt=null,this.Pt=null,this.Et=null,this.W.clearHover(),this.f.clear(),this.qt.clear(),this.zo=null,this.Xo=null,this.$o=null,this.L=[],this.U=[],Zs(this)}},To=class extends ft{constructor(){super(new Dt)}},Ro=class extends ft{constructor(){super(new Bt)}},wo=class extends ft{constructor(){super(new Pt)}}});function yl(e,t){if(t>xl||t<-xl)return[NaN,NaN];let n=e*Math.PI*6378137/180,o=t*Math.PI/180,i=6378137*Math.log(Math.tan(Math.PI/4+o/2));return[n,i]}function Cl(e,t,n){let o=1<<e,i=2*Ue/o,r=-Ue+t*i,s=r+i,a=Ue-n*i,l=a-i;return{xMin:r,yMin:l,xMax:s,yMax:a}}function _l(e,t=256,n=19){if(!isFinite(e)||e<=0)return 0;let o=Math.log2(2*Ue/(t*e));return Math.max(0,Math.min(n,Math.floor(o)))}function vl(e,t){let n=1<<t,o=2*Ue/n,i=Math.floor((e.xMin+Ue)/o),r=Math.floor((e.xMax+Ue)/o),s=Math.floor((Ue-e.yMax)/o),a=Math.floor((Ue-e.yMin)/o),l=[];for(let u=s;u<=a;u++)if(!(u<0||u>=n))for(let m=i;m<=r;m++)m<0||m>=n||l.push({z:t,x:m,y:u});return l}var Ue,xl,kr=G(()=>{\"use strict\";Ue=Math.PI*6378137,xl=85.0511287798066});var gi,Al=G(()=>{\"use strict\";gi=class{constructor(t=256){c(this,\"ve\",new Map);c(this,\"ji\");this.ji=t}get(t){let n=this.ve.get(t);return n!==void 0&&(this.ve.delete(t),this.ve.set(t,n)),n}set(t,n,o){if(this.ve.has(n)){let i=this.ve.get(n);t.deleteTexture(i),this.ve.delete(n)}for(this.ve.set(n,o);this.ve.size>this.ji;){let i=this.ve.keys().next().value;if(i===void 0)break;let r=this.ve.get(i);t.deleteTexture(r),this.ve.delete(i)}}has(t){return this.ve.has(t)}dispose(t){for(let n of this.ve.values())t.deleteTexture(n);this.ve.clear()}}});function Vt(e,t,n,o){return`${e}/${t}/${n}/${o}`}var hi,Ll=G(()=>{\"use strict\";hi=class{constructor(){c(this,\"Ae\",new Map);c(this,\"Zi\",()=>{})}setOnLoad(t){this.Zi=t}load(t,n,o,i){let r=Vt(t.id,n,o,i),s=this.Ae.get(r);if(s)return s.promise;let a=new AbortController,l=t.urlFor(n,o,i),u=this.ar(l,a.signal).then(m=>(this.Ae.delete(r),m&&this.Zi(),m)).catch(()=>(this.Ae.delete(r),null));return this.Ae.set(r,{promise:u,abort:a}),u}cancelAll(){for(let t of this.Ae.values())t.abort.abort();this.Ae.clear()}cancelExcept(t){for(let[n,o]of this.Ae)t.has(n)||(o.abort.abort(),this.Ae.delete(n))}async ar(t,n){let o=await fetch(t,{signal:n});if(!o.ok)return null;let i=await o.blob();return await createImageBitmap(i)}}});var xi,Tl=G(()=>{\"use strict\";kr();Al();Ll();Bi();Pi();fe();xi=class{constructor(){c(this,\"o\",null);c(this,\"k\",null);c(this,\"d\",new gi);c(this,\"kn\",new hi);c(this,\"Nn\",null);c(this,\"qi\",1);c(this,\"Ki\",()=>{})}setOnTileLoad(t){this.Ki=t,this.kn.setOnLoad(t)}setSource(t,n){this.Nn?.id!==n.id&&(this.d.dispose(t),this.kn.cancelAll(),this.Nn=n)}setAlpha(t){this.qi=Math.max(0,Math.min(1,t))}get source(){return this.Nn}render(t,n,o,i,r,s){let a=this.Nn;if(!a)return;this.lr(t);let l=this.o,u=this.k;if(!l||!u)return;let m=t.gl,f=t.dpr,p=Math.max(1,n.e.width*f),d=i.xMax-i.xMin;if(!isFinite(d)||d<=0)return;let b=d/p,x=_l(b,a.tileSize,a.maxZoom),h=vl(i,x),g=new Set;for(let _ of h)g.add(Vt(a.id,_.z,_.x,_.y));this.kn.cancelExcept(g),m.useProgram(l.program),m.uniformMatrix4fv(l.u_projection,!1,o),m.uniform1f(l.u_alpha,this.qi),m.bindBuffer(m.ARRAY_BUFFER,u),m.enableVertexAttribArray(l.a_corner),m.vertexAttribPointer(l.a_corner,2,m.FLOAT,!1,0,0),m.activeTexture(m.TEXTURE0),m.uniform1i(l.u_tile,0);let y=m.isEnabled(m.BLEND);m.enable(m.BLEND),m.blendFunc(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA);for(let _ of h)this.ur(m,l,a,_,r,s);y||m.disable(m.BLEND)}destroy(t){this.kn.cancelAll(),this.d.dispose(t),this.k&&(t.deleteBuffer(this.k),this.k=null),this.o=null}ur(t,n,o,i,r,s){let a=Cl(i.z,i.x,i.y),l={xMin:a.xMin-r,xMax:a.xMax-r,yMin:a.yMin-s,yMax:a.yMax-s},u=Vt(o.id,i.z,i.x,i.y),m=this.d.get(u);if(m){this.Ji(t,n,m,l,[0,0],[1,1]);return}this.mr(t,o,i);for(let f=1;f<=6;f++){let p=i.z-f;if(p<0)return;let d=i.x>>f,b=i.y>>f,x=Vt(o.id,p,d,b),h=this.d.get(x);if(!h)continue;let g=1<<f,y=i.x-d*g,_=i.y-b*g,C=1/g,v=[y*C,_*C],A=[v[0]+C,v[1]+C];this.Ji(t,n,h,l,v,A);return}}Ji(t,n,o,i,r,s){t.bindTexture(t.TEXTURE_2D,o),t.uniform2f(n.u_extent_min,i.xMin,i.yMin),t.uniform2f(n.u_extent_max,i.xMax,i.yMax),t.uniform2f(n.u_uv_min,r[0],r[1]),t.uniform2f(n.u_uv_max,s[0],s[1]),t.drawArrays(t.TRIANGLE_STRIP,0,4)}mr(t,n,o){let i=Vt(n.id,o.z,o.x,o.y);this.d.has(i)||this.kn.load(n,o.z,o.x,o.y).then(r=>{if(!r)return;if(this.Nn?.id!==n.id){r.close();return}let s=t.createTexture();if(!s){r.close();return}t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r),this.d.set(t,i,s),this.Ki()})}lr(t){if(this.o&&this.k)return;let n=t.gl;this.o=j(t,\"map-tile\",Kn,Jn,[\"u_projection\",\"u_extent_min\",\"u_extent_max\",\"u_uv_min\",\"u_uv_max\",\"u_tile\",\"u_alpha\"],[\"a_corner\"]);let o=n.createBuffer();o&&(n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),this.k=o)}}});function Pf(){return new wn(\"carto-positron\",\"https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png\",\"\\xA9 OpenStreetMap contributors \\xA9 CARTO\",256,19,[\"a\",\"b\",\"c\",\"d\"])}function Ef(){return new wn(\"carto-dark-matter\",\"https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}.png\",\"\\xA9 OpenStreetMap contributors \\xA9 CARTO\",256,19,[\"a\",\"b\",\"c\",\"d\"])}function Gf(){return new wn(\"carto-voyager\",\"https://{s}.basemaps.cartocdn.com/rastertiles/voyager/{z}/{x}/{y}.png\",\"\\xA9 OpenStreetMap contributors \\xA9 CARTO\",256,19,[\"a\",\"b\",\"c\",\"d\"])}function Nr(e){switch(e){case\"carto-dark-matter\":return Ef();case\"carto-voyager\":return Gf();case\"carto-positron\":default:return Pf()}}var wn,Rl=G(()=>{\"use strict\";wn=class{constructor(t,n,o,i=256,r=19,s=[]){this.id=t;this.template=n;this.attribution=o;this.tileSize=i;this.maxZoom=r;this.subdomains=s}urlFor(t,n,o){let i=this.template.replace(\"{z}\",String(t)).replace(\"{x}\",String(n)).replace(\"{y}\",String(o));if(this.subdomains.length>0){let r=(n+o)%this.subdomains.length;i=i.replace(\"{s}\",this.subdomains[r])}return i}}});var yi={};Hl(yi,{MapChart:()=>Ht,MapDensityChart:()=>Vr,MapLineChart:()=>Or,MapScatterChart:()=>Ur});var Ht,Ur,Or,Vr,Ci=G(()=>{\"use strict\";rr();tr();nr();ir();Tl();Rl();kr();ut();Ht=class extends ft{constructor(n){super(n);c(this,\"Cn\",\"map\");c(this,\"Je\");this.Je=new xi,this.Je.setOnTileLoad(()=>{this.t&&this.requestRender(this.t)})}projectPoint(n,o){return yl(n,o)}getZoomConfig(){return{lockAspect:!0}}setPluginConfig(n){super.setPluginConfig(n),this.t&&this.Je.setSource(this.t.gl,Nr(n.map_tile_provider)),this.Je.setAlpha(n.map_tile_alpha)}renderBackground(n,o,i,r,s,a){this.Je.source||(this.Je.setSource(n.gl,Nr(this.h.map_tile_provider)),this.Je.setAlpha(this.h.map_tile_alpha)),this.Je.render(n,o,i,r,s,a)}renderMapChrome(n,o,i,r){if(!n)return;let s=re(n,r);if(!s)return;let a=this.Je.source?.attribution??\"\";if(!a)return;let l=o.e;s.save(),s.font=`10px ${i.fontFamily}`,s.textAlign=\"right\",s.textBaseline=\"bottom\";let u=4,f=s.measureText(a).width,p=12,d=l.x+l.width-4,b=l.y+l.height-4;s.fillStyle=\"rgba(255, 255, 255, 0.75)\",s.fillRect(d-f-u*2,b-p-u,f+u*2,p+u),s.fillStyle=i.Le,s.fillText(a,d-u,b-u/2),s.restore()}destroyInternal(){this.t&&this.Je.destroy(this.t.gl),super.destroyInternal()}},Ur=class extends Ht{constructor(){super(new Dt)}},Or=class extends Ht{constructor(){super(new Bt)}},Vr=class extends Ht{constructor(){super(new Pt)}}});typeof window>\"u\"&&(globalThis.window={});var jt=class{constructor(t){c(this,\"dt\");c(this,\"i\",new Map);c(this,\"sn\",0);c(this,\"Un\",0);this.dt=t}get totalCapacity(){return this.sn}get maxCapacity(){return this.Un}set maxCapacity(t){this.Un=t}ensureCapacity(t){this.sn=this.Un>0?Math.min(t,this.Un):t}peek(t){return this.i.get(t)}getOrCreate(t,n,o){let i=this.sn*n*o,r=this.i.get(t);if(r&&r.byteCapacity>=i)return r;let s=this.dt;r&&s.deleteBuffer(r.buffer);let a=s.createBuffer();return s.bindBuffer(s.ARRAY_BUFFER,a),s.bufferData(s.ARRAY_BUFFER,i,s.DYNAMIC_DRAW),r={buffer:a,byteCapacity:i},this.i.set(t,r),r}upload(t,n,o,i=1){let r=this.dt,s=this.getOrCreate(t,i,n.BYTES_PER_ELEMENT);if(!1){let a=o+n.byteLength;if(a>s.byteCapacity)throw new Error(`BufferPool.upload(\"${t}\"): write ${o}..${a} exceeds capacity ${s.byteCapacity} (_totalCapacity=${this.sn}, components=${i}, bytes=${n.BYTES_PER_ELEMENT}). Did you pass the full scratch buffer instead of a subarray(0, n)?`)}return r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.bufferSubData(r.ARRAY_BUFFER,o,n),s.buffer}releaseAll(){for(let t of this.i.values())this.dt.deleteBuffer(t.buffer);this.i.clear(),this.sn=0}};var Zt=class{constructor(t){c(this,\"dt\");c(this,\"On\",new Map);this.dt=t}precompile(t){for(let n of t)this.getOrCreate(n.name,n.vert,n.frag)}getOrCreate(t,n,o){let i=this.On.get(t);if(i)return i;let r=this.dt,s=r.createShader(r.VERTEX_SHADER);if(r.shaderSource(s,n),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)){let l=r.getShaderInfoLog(s);throw r.deleteShader(s),new Error(`Vertex shader compile error [${t}]: ${l}`)}let a=r.createShader(r.FRAGMENT_SHADER);if(r.shaderSource(a,o),r.compileShader(a),!r.getShaderParameter(a,r.COMPILE_STATUS)){let l=r.getShaderInfoLog(a);throw r.deleteShader(s),r.deleteShader(a),new Error(`Fragment shader compile error [${t}]: ${l}`)}if(i=r.createProgram(),r.attachShader(i,s),r.attachShader(i,a),r.linkProgram(i),!r.getProgramParameter(i,r.LINK_STATUS)){let l=r.getProgramInfoLog(i);throw r.deleteProgram(i),r.deleteShader(s),r.deleteShader(a),new Error(`Shader link error [${t}]: ${l}`)}return r.deleteShader(s),r.deleteShader(a),this.On.set(t,i),i}releaseAll(){for(let t of this.On.values())this.dt.deleteProgram(t);this.On.clear()}};var Fn=\"attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;attribute float a_series_id;attribute float a_axis;uniform mat4 u_proj_left;uniform mat4 u_proj_right;uniform float u_hover_series;uniform float u_horizontal;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec2 A;if(u_horizontal>0.5){A=vec2(mix(a_y0,a_y1,a_corner.x),a_x_center+(a_corner.y-0.5)*2.*a_half_width);}else{A=vec2(a_x_center+(a_corner.x-0.5)*2.*a_half_width,mix(a_y0,a_y1,a_corner.y));}mat4 B=a_axis<0.5?u_proj_left:u_proj_right;gl_Position=B*vec4(A,0.,1.);v_color=a_color;v_hover=abs(a_series_id-u_hover_series)<0.5?1.:0.;v_local=a_corner;}\";var Sn=\"precision highp float;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec3 A=v_color;if(v_hover>0.5){A=mix(A,vec3(1.),0.25);}gl_FragColor=vec4(A,1.);}\";Li();Ti();Ri();wi();var En=\"attribute vec2 a_position;uniform mat4 u_projection;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);}\";var Gn=\"precision highp float;uniform vec3 u_color;uniform float u_opacity;void main(){gl_FragColor=vec4(u_color,u_opacity);}\";var Oe=\"attribute vec2 a_start;attribute vec2 a_end;attribute float a_corner;attribute float a_real_start;attribute float a_real_end;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform float u_interp_alpha;varying float v_edge_dist;varying float v_seg_alpha;void main(){vec4 A=u_projection*vec4(a_start,0.,1.);vec4 B=u_projection*vec4(a_end,0.,1.);vec2 C=A.xy*u_resolution*0.5;vec2 D=B.xy*u_resolution*0.5;vec2 E=D-C;float F=length(E);E=F>0.001?E/F:vec2(1.,0.);vec2 G=vec2(-E.y,E.x);float H=step(1.5,a_corner);float I=1.-mod(a_corner,2.)*2.;vec4 J=mix(A,B,H);float K=(u_line_width+1.5)*0.5;vec2 L=(G*I*K)/(u_resolution*0.5);gl_Position=J+vec4(L,0.,0.);v_edge_dist=I;float M=a_real_start*a_real_end;v_seg_alpha=mix(u_interp_alpha,1.,step(0.5,M));}\";var Ve=\"precision highp float;uniform vec4 u_color;uniform float u_line_width;varying float v_edge_dist;varying float v_seg_alpha;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(u_color.rgb,u_color.a*C*v_seg_alpha);}\";var Wn=\"attribute vec2 a_position;attribute vec3 a_color;uniform mat4 u_projection;uniform float u_point_size;varying vec3 v_color;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);gl_PointSize=u_point_size;v_point_size=u_point_size;v_color=a_color;}\";var kn=\"precision highp float;varying vec3 v_color;varying float v_point_size;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5)discard;float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);gl_FragColor=vec4(v_color,D);}\";var Nn=\"attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;uniform mat4 u_projection;varying vec3 v_color;void main(){float A=a_x_center+(a_corner.x-0.5)*2.*a_half_width;float B=mix(a_y0,a_y1,a_corner.y);gl_Position=u_projection*vec4(A,B,0.,1.);v_color=a_color;}\";var Un=\"precision highp float;varying vec3 v_color;void main(){gl_FragColor=vec4(v_color,1.);}\";var On=\"attribute vec2 a_corner;attribute vec2 a_cell;attribute float a_color_t;uniform mat4 u_projection;uniform vec2 u_cell_inset;uniform vec2 u_cell_size;varying float v_color_t;void main(){vec2 A=0.5*u_cell_size;vec2 B=u_cell_size-2.*u_cell_inset;float C=a_cell.x-A.x+u_cell_inset.x+a_corner.x*B.x;float D=a_cell.y-A.y+u_cell_inset.y+a_corner.y*B.y;gl_Position=u_projection*vec4(C,D,0.,1.);v_color_t=a_color_t;}\";var Vn=\"precision highp float;uniform sampler2D u_gradient_lut;varying float v_color_t;void main(){float A=clamp(v_color_t,0.,1.);vec4 B=texture2D(u_gradient_lut,vec2(A,0.5));gl_FragColor=vec4(B.rgb,1.);}\";var Hn=\"attribute float a_strip_t;attribute float a_side;attribute vec2 a_angles;attribute vec2 a_radii;attribute vec4 a_color;uniform vec2 u_center;uniform vec2 u_resolution;uniform float u_border_px;varying vec4 v_color;varying vec2 v_edge;void main(){float A=u_border_px*0.5;float B=a_radii.x+A;float C=a_radii.y-A;if(C<=B){gl_Position=vec4(2.,2.,2.,1.);v_color=vec4(0.);v_edge=vec2(0.);return;}float D=mix(B,C,a_side);float E=A/max(D,1.);float F=a_angles.y-a_angles.x;E=min(E,F*0.5);float G=mix(a_angles.x+E,a_angles.y-E,a_strip_t);vec2 H=u_center+vec2(cos(G),sin(G))*D;vec2 I=(H/u_resolution)*2.-1.;gl_Position=vec4(I.x,-I.y,0.,1.);v_color=a_color;v_edge=vec2(a_strip_t,a_side);}\";var Yn=\"precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}\";var zn=\"attribute vec2 a_position;attribute vec4 a_color;uniform vec2 u_resolution;varying vec4 v_color;void main(){vec2 A=(a_position/u_resolution)*2.-1.;A.y=-A.y;gl_Position=vec4(A,0.,1.);v_color=a_color;}\";var Xn=\"precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}\";Mi();Fi();Si();Ii();Di();Bi();Pi();var Ei=[{name:\"bar\",vert:Fn,frag:Sn},{name:\"line\",vert:In,frag:Dn},{name:\"scatter\",vert:Bn,frag:Pn},{name:\"bar-area\",vert:En,frag:Gn},{name:\"bar-scatter\",vert:Wn,frag:kn},{name:\"line-uniform\",vert:Oe,frag:Ve},{name:\"candlestick-body\",vert:Nn,frag:Un},{name:\"heatmap\",vert:On,frag:Vn},{name:\"sunburst-arc\",vert:Hn,frag:Yn},{name:\"treemap\",vert:zn,frag:Xn},{name:\"density-splat\",vert:xt,frag:$n},{name:\"density-extreme\",vert:xt,frag:jn},{name:\"density-resolve\",vert:Zn,frag:qn},{name:\"map-tile\",vert:Kn,frag:Jn}];var Cu=1,ot=class{constructor(t,n={}){c(this,\"id\");c(this,\"canvas\");c(this,\"gl\");c(this,\"isWebGL2\");c(this,\"shaders\");c(this,\"xi\");c(this,\"yi\",null);c(this,\"Ht\");c(this,\"pt\",!1);c(this,\"Vn\",new Set);this.id=Cu++,this.canvas=t,this.Ht=n.precompile??!1;let o=t.getContext(\"webgl2\",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(o)this.gl=o,this.isWebGL2=!0;else{let i=t.getContext(\"webgl\",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(!i)throw new Error(\"WebGL is not supported\");this.gl=i,this.isWebGL2=!1}this.shaders=new Zt(this.gl),this.Ht&&this.shaders.precompile(Ei),this.xi=this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),this.isWebGL2||(this.yi=this.gl.getExtension(\"ANGLE_instanced_arrays\")),t.addEventListener(\"webglcontextlost\",i=>{this.pt||i.preventDefault()}),t.addEventListener(\"webglcontextrestored\",()=>{this.shaders.releaseAll(),this.shaders=new Zt(this.gl),this.Ht&&this.shaders.precompile(Ei);for(let i of this.Vn)i()})}resetVertexArrayState(){let t=this.gl;for(let n=0;n<this.xi;n++)t.disableVertexAttribArray(n),this.isWebGL2?t.vertexAttribDivisor(n,0):this.yi?.vertexAttribDivisorANGLE(n,0)}onRestore(t){return this.Vn.add(t),()=>this.Vn.delete(t)}isContextLost(){return this.pt||this.gl.isContextLost()}get destroyed(){return this.pt}destroy(){this.pt=!0,this.Vn.clear(),this.shaders.releaseAll();let t=this.gl.getExtension(\"WEBGL_lose_context\");t&&t.loseContext()}};var qt=class{constructor(t,n={}){c(this,\"S\");c(this,\"Hn\");c(this,\"Ci\");c(this,\"i\");c(this,\"Yn\",0);c(this,\"Bo\",0);c(this,\"Po\",0);c(this,\"Eo\",1);c(this,\"pt\",!1);c(this,\"zn\",null);c(this,\"bt\",null);c(this,\"an\",null);c(this,\"Yt\",null);t instanceof ot?(this.S=t,this.Hn=!1):(this.S=new ot(t,{precompile:n.precompile??!1}),this.Hn=!0),this.i=new jt(this.S.gl),this.Ci=this.S.onRestore(()=>{this.i.releaseAll(),this.i=new jt(this.S.gl),this.Yn=0})}get gl(){return this.S.gl}get backendId(){return this.S.id}isContextLost(){return this.pt||this.S.isContextLost()}get isWebGL2(){return this.S.isWebGL2}get shaders(){return this.S.shaders}get v(){return this.i}get uploadedCount(){return this.Yn}set uploadedCount(t){this.Yn=t}resize(t,n,o){this.Bo=t,this.Po=n,this.Eo=o;let i=Math.round(t*o),r=Math.round(n*o),s=this.S.canvas;(s.width!==i||s.height!==r)&&(s.width=i,s.height=r,this.S.gl.viewport(0,0,i,r))}requestResize(t,n,o){this.Yt={cssWidth:t,cssHeight:n,dpr:o}}applyPendingResize(){if(!this.Yt)return!1;let{cssWidth:t,cssHeight:n,dpr:o}=this.Yt;return this.Yt=null,this.resize(t,n,o),!0}beginFrame(){if(this.Hn){this.applyPendingResize();return}let t=this.Yt;this.Yt=null,t?this.resize(t.cssWidth,t.cssHeight,t.dpr):this.resize(this.Bo,this.Po,this.Eo);let n=this.S.gl,o=this.S.canvas;n.bindFramebuffer(n.FRAMEBUFFER,null),n.viewport(0,0,o.width,o.height),n.disable(n.SCISSOR_TEST),n.disable(n.DEPTH_TEST),this.S.resetVertexArrayState()}get cssWidth(){return this.Bo}get cssHeight(){return this.Po}get dpr(){return this.Eo}clear(){this.S.gl.clearColor(0,0,0,0),this.S.gl.clear(this.S.gl.COLOR_BUFFER_BIT|this.S.gl.DEPTH_BUFFER_BIT),this.Yn=0}setFrameCallback(t){this.zn=t}endFrame(){if(!this.zn||this.isContextLost())return;let t=this.S.canvas;if(typeof t.transferToImageBitmap!=\"function\")return;let n=t.transferToImageBitmap();this.zn(n)}async awaitGpuFence(){if(!this.S.isWebGL2){this.S.gl.finish();return}let t=this.S.gl,n=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n){t.finish();return}try{let o=t.SYNC_FLUSH_COMMANDS_BIT;for(;;){let i=t.clientWaitSync(n,o,0);if(i===t.ALREADY_SIGNALED||i===t.CONDITION_SATISFIED)return;if(i===t.WAIT_FAILED){t.finish();return}if(o=0,await this.er(),this.pt)return}}finally{t.deleteSync(n)}}ensureBufferCapacity(t){this.i.ensureCapacity(t)}er(){return this.bt||(this.bt=new MessageChannel,this.bt.port1.start()),new Promise(t=>{let n=this.bt;this.an=t,n.port1.addEventListener(\"message\",()=>{this.an=null,t()},{once:!0}),n.port2.postMessage(null)})}destroy(){if(this.pt=!0,this.zn=null,this.Ci(),this.i.releaseAll(),this.an){let t=this.an;this.an=null,t()}this.bt&&(this.bt.port1.close(),this.bt.port2.close(),this.bt=null),this.Hn&&this.S.destroy()}};var Qn=class{constructor(t,n={}){c(this,\"_i\");c(this,\"Ht\");c(this,\"zt\",[]);c(this,\"vi\",0);this._i=Math.max(1,t),this.Ht=n.precompile??!1}acquire(){let t;if(this.zt.length<this._i)t=this.Ai(),this.zt.push(t);else{let n=this.vi%this.zt.length;this.vi++,this.zt[n].isContextLost()&&(this.zt[n]=this.Ai()),t=this.zt[n]}return t}Ai(){let t=new OffscreenCanvas(1,1);return new ot(t,{precompile:this.Ht})}};eo();eo();function ts(e,t,n,o){let{controller:i,layout:r}=e,s=r.e,a=i.getVisibleDomain(),l=a.xMin+(t-s.x)/s.width*(a.xMax-a.xMin),u=a.yMax-(n-s.y)/s.height*(a.yMax-a.yMin),m=Math.pow(1.1,-o/100),f=i.lockedAxis;f!==\"x\"&&(i.scaleX=Math.max(1,Math.min(1e5,i.scaleX*m))),f!==\"y\"&&(i.scaleY=Math.max(1,Math.min(1e5,i.scaleY*m)));let p=i.getVisibleDomain(),d=p.xMin+(t-s.x)/s.width*(p.xMax-p.xMin),b=p.yMax-(n-s.y)/s.height*(p.yMax-p.yMin),x=i.baseXRange,h=i.baseYRange;f!==\"x\"&&x>0&&(i.normTranslateX+=(l-d)/x),f!==\"y\"&&h>0&&(i.normTranslateY+=(u-b)/h)}function ns(e,t,n){let{controller:o,layout:i}=e,r=o.getVisibleDomain(),s=i.e,a=(r.xMax-r.xMin)/s.width,l=(r.yMax-r.yMin)/s.height,u=o.lockedAxis,m=o.baseXRange,f=o.baseYRange;u!==\"x\"&&m>0&&(o.normTranslateX-=t*a/m),u!==\"y\"&&f>0&&(o.normTranslateY+=n*l/f)}var to=class{constructor(t){c(this,\"Xt\");this.Xt=t}pin(t,n,o){this.Xt({kind:\"pinTooltip\",lines:t,pos:n,bounds:o})}dismiss(){this.Xt({kind:\"dismissTooltip\"})}setCursor(t){this.Xt({kind:\"setCursor\",cursor:t})}emitUserClick(t){this.Xt({kind:\"userClick\",detail:t})}emitUserSelect(t){this.Xt({kind:\"userSelect\",selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig})}};rr();Jt();var Mo=class{constructor(t=1024){c(this,\"size\");c(this,\"value\");c(this,\"colorValue\");c(this,\"sizeSign\");c(this,\"x0\");c(this,\"y0\");c(this,\"x1\");c(this,\"y1\");c(this,\"a0\");c(this,\"a1\");c(this,\"r0\");c(this,\"r1\");c(this,\"depth\");c(this,\"parent\");c(this,\"firstChild\");c(this,\"nextSibling\");c(this,\"lastChild\");c(this,\"childCount\");c(this,\"leafRowIdx\");c(this,\"name\");c(this,\"colorLabel\");c(this,\"count\",0);c(this,\"capacity\",0);this.Ni(t)}reset(){this.count>0&&(this.x0.fill(0,0,this.count),this.y0.fill(0,0,this.count),this.x1.fill(0,0,this.count),this.y1.fill(0,0,this.count),this.a0.fill(0,0,this.count),this.a1.fill(0,0,this.count),this.r0.fill(0,0,this.count),this.r1.fill(0,0,this.count)),this.count=0}allocate(){this.count===this.capacity&&this.Ni(this.capacity*2);let t=this.count++;return this.firstChild[t]=-1,this.nextSibling[t]=-1,this.lastChild[t]=-1,this.childCount[t]=0,this.leafRowIdx[t]=-1,this.size[t]=0,this.value[t]=0,this.colorValue[t]=NaN,this.sizeSign[t]=1,this.name[t]=\"\",this.colorLabel[t]=\"\",t}appendChild(t,n){this.parent[n]=t,this.depth[n]=this.depth[t]+1,this.nextSibling[n]=-1;let o=this.lastChild[t];o===-1?this.firstChild[t]=n:this.nextSibling[o]=n,this.lastChild[t]=n,this.childCount[t]++}isLeaf(t){return this.firstChild[t]===-1}Ni(t){let n=Math.max(t,1024),o=(i,r)=>{let s=new r(n);return i&&i.length>0&&s.set(i),s};this.size=o(this.size,Float32Array),this.value=o(this.value,Float32Array),this.colorValue=o(this.colorValue,Float32Array),this.sizeSign=o(this.sizeSign,Int8Array),this.x0=o(this.x0,Float32Array),this.y0=o(this.y0,Float32Array),this.x1=o(this.x1,Float32Array),this.y1=o(this.y1,Float32Array),this.a0=o(this.a0,Float32Array),this.a1=o(this.a1,Float32Array),this.r0=o(this.r0,Float32Array),this.r1=o(this.r1,Float32Array),this.depth=o(this.depth,Int32Array),this.parent=o(this.parent,Int32Array),this.firstChild=o(this.firstChild,Int32Array),this.nextSibling=o(this.nextSibling,Int32Array),this.lastChild=o(this.lastChild,Int32Array),this.childCount=o(this.childCount,Int32Array),this.leafRowIdx=o(this.leafRowIdx,Int32Array),this.name?this.name.length=n:this.name=new Array(n),this.colorLabel?this.colorLabel.length=n:this.colorLabel=new Array(n),this.capacity=n}};function oa(e,t){let n=[],o=t;for(;e.parent[o]!==-1;)n.push(e.name[o]),o=e.parent[o];return n.reverse()}Qi();function Fo(e){for(let t of e.keys())if(!t.startsWith(\"__\"))return t;return\"\"}var Et=class extends Te{constructor(){super(...arguments);c(this,\"ne\",\"\");c(this,\"a\",\"\");c(this,\"ye\",\"empty\");c(this,\"r\",new Mo);c(this,\"X\",-1);c(this,\"C\",-1);c(this,\"le\",[]);c(this,\"Gt\",new Map);c(this,\"go\",0);c(this,\"b\",1/0);c(this,\"p\",-1/0);c(this,\"f\",new Map);c(this,\"$\",null);c(this,\"ie\",0);c(this,\"W\",new It)}};Qt();un();Ae();function ct(e,t,n,o,i){if(!e||t<=0)return null;let r=new Float64Array(t),s=1/0,a=-1/0;for(let u=0;u<t;u++){let m=e[u+n];r[u]=m,m<s&&(s=m),m>a&&(a=m)}let l=1/0;for(let u=1;u<t;u++){let m=Math.abs(r[u]-r[u-1]);m>0&&m<l&&(l=m)}return(!isFinite(l)||l===0)&&(l=Math.max(1,a-s)),{categoryPositions:r,numericCategoryDomain:{min:s-l/2,max:a+l/2,isDate:i,label:o,bandWidth:l}}}function Gt(e,t){if(e.length!==1)return{mode:\"category\"};let n=t[e[0]];return n===\"date\"||n===\"datetime\"||n===\"integer\"||n===\"float\"?{mode:\"numeric\",numericType:n}:{mode:\"category\"}}function Cm(e,t,n){return!t||e==null||Number.isNaN(e)?\"\":n===\"boolean\"?e?\"true\":\"false\":n===\"date\"||n===\"datetime\"?ye(e):n===\"integer\"?String(e|0):n===\"float\"?me(e):String(e)}function sr(e,t,n){let o=e.values,i=e.valid,r=new Int32Array(t),s=[\"\"],a=new Map;a.set(\"\",0);for(let l=0;l<t;l++){let u=i?!!(i[l>>3]>>(l&7)&1):!0,m=o[l],f=Cm(m,u,n),p=a.get(f);p===void 0&&(p=s.length,s.push(f),a.set(f,p)),r[l]=p}return{indices:r,dictionary:s}}function Wt(e,t,n,o=[]){let i=[];for(let u=0;;u++){let m=e.get(`__ROW_PATH_${u}__`);if(!m)break;if(m.type===\"string\"&&m.indices&&m.dictionary)i.push({indices:m.indices,dictionary:m.dictionary});else if(m.values){let f=o[u]??\"string\";i.push(sr(m,t,f))}else break}let r=0;if(n>0&&i.length>0)for(;r<t;){let u=!1;for(let m of i){let f=m.dictionary[m.indices[r]];if(f!=null&&f!==\"\"){u=!0;break}}if(u)break;r++}let s=Math.max(0,t-r),a=i.length;return{rowPaths:n>0&&a>0?i.map((u,m)=>{let f=new Array(s),p=0;for(let b=0;b<s;b++){let x=u.dictionary[u.indices[b+r]]??\"\";f[b]=x,x.length>p&&(p=x.length)}let d=m===a-1?[]:go(u.indices,u.dictionary,r,r+s).map(b=>({startIdx:b.startIdx-r,endIdx:b.endIdx-r,label:b.label}));return{labels:f,runs:d,maxLabelChars:p}}):[],numCategories:s,rowOffset:r}}function ar(e,t,n,o){if(e.length===0)return null;for(let p of e)if(p.type!==\"string\")return null;let i=Math.max(0,t-n),r=[],s=new Map,a=e.map(()=>new Int32Array(i)),l=p=>{let d=s.get(p);return d===void 0&&(d=r.length,r.push(p),s.set(p,d)),d};for(let p=0;p<e.length;p++){let d=e[p].data,b=a[p];for(let x=0;x<i;x++){let h=x+n,g;if(!d)g=\"(null)\";else{let y=d.valid;if(!(y?!!(y[h>>3]>>(h&7)&1):!0))g=\"(null)\";else if(d.indices&&d.dictionary)g=d.dictionary[d.indices[h]]??\"(null)\";else if(d.values){let C=d.values[h];g=C==null?\"(null)\":String(C)}else g=\"(null)\"}b[x]=l(g)}}let u=0;for(let p of r)p.length>u&&(u=p.length);return{domain:{levels:[{labels:r.slice(),runs:[],maxLabelChars:u}],numRows:r.length,levelLabels:[o]},perColumnSlots:a}}function dn(e){e.r.reset(),e.Gt.clear();let t=e.r.allocate();e.r.name[t]=\"Total\",e.r.depth[t]=0,e.r.parent[t]=-1,e.Gt.set(t,new Map),e.X=t,e.C=t,e.le=[t],e.go=0,e.b=1/0,e.p=-1/0,e.f.clear(),e.$=null,e.ie=0}function _m(e,t,n){let o=e.Gt.get(t);o||(o=new Map,e.Gt.set(t,o));let i=o.get(n);if(i!==void 0)return i;let r=e.r.allocate();return e.r.name[r]=n,e.r.appendChild(t,r),o.set(n,r),r}function So(e,t,n,o,i,r,s){let a=e.X,l=t.length;for(let u=0;u<l;u++){let m=_m(e,a,t[u]);u===l-1&&((s===0||l===s)&&(e.r.size[m]=Math.abs(n),e.r.sizeSign[m]=n<0?-1:1,e.r.leafRowIdx[m]=r),isNaN(o)||(e.r.colorValue[m]=o,o<e.b&&(e.b=o),o>e.p&&(e.p=o)),i&&(e.r.colorLabel[m]=i,e.f.has(i)||e.f.set(i,e.f.size))),a=m}}function ra(e,t){let n=e.valid;return!n||!!(n[t>>3]>>(t&7)&1)}function Io(e,t){return e?.values?ra(e,t)?e.values[t]:0:1}function Do(e,t,n){let o=NaN,i=\"\";return!t||!ra(t,n)?{colorValue:o,colorLabel:i}:(e.ye===\"numeric\"&&t.values?o=t.values[n]:e.ye===\"series\"&&t.indices&&t.dictionary&&(i=t.dictionary[t.indices[n]]),{colorValue:o,colorLabel:i})}function ia(e,t){if(e.ye!==\"series\"||!t?.dictionary)return;let n=t.dictionary;for(let o=0;o<n.length;o++){let i=n[o];e.f.has(i)||e.f.set(i,e.f.size)}}function vm(e,t){if(e.B.length===0)return null;let n=e.ne?[e.ne]:[],o=e.a?[e.a]:[],i=He(t,n,o);return i.length===0?null:i.map(r=>({prefix:r.prefix,sizeCol:e.ne?t.get(`${r.prefix}|${e.ne}`)??null:null,colorCol:e.a?t.get(`${r.prefix}|${e.a}`)??null:null}))}function pn(e,t){let n=[];for(let x=0;;x++){let h=t.get(`__ROW_PATH_${x}__`);if(!h)break;if(h.type===\"string\"&&h.indices&&h.dictionary)n.push({indices:h.indices,dictionary:h.dictionary,valid:h.valid});else if(h.values){let g=e._[x],y=e.ht[g]??\"string\";n.push(sr(h,h.values.length,y))}else break}let o=n.length>0,i=e._.length,r=vm(e,t),s=r!==null,a=e.ne?t.get(e.ne):null,l=e.a?t.get(e.a):null,u=s?r[0].sizeCol:a,m=o?n[0].indices.length:u?.values?.length??0;if(m===0)return;if(s)for(let x of r)ia(e,x.colorCol);else ia(e,l);let f=e.go,p=s&&o?i+1:i;if(!o){let x;for(let[g,y]of t){if(g.startsWith(\"__\")||s&&g.includes(\"|\"))continue;let _=g.lastIndexOf(\"|\"),C=_===-1?g:g.substring(_+1);if(!(C===e.ne||C===e.a)&&y.type===\"string\"&&y.indices&&y.dictionary){x=y;break}}let h=s?r:null;for(let g=0;g<m;g++){let y=x?.indices&&x?.dictionary?x.dictionary[x.indices[g]]:`Row ${f+g}`;if(h)for(let _ of h){let C=Io(_.sizeCol,g),{colorValue:v,colorLabel:A}=Do(e,_.colorCol,g);So(e,[_.prefix,y],C,v,A,f+g,p)}else{let _=Io(a,g),{colorValue:C,colorLabel:v}=Do(e,l,g);So(e,[y],_,C,v,f+g,p)}}e.go=f+m;return}let d=s?1:0,b=new Array(n.length+d);for(let x=0;x<m;x++){let h=0;for(let g=0;g<n.length;g++){let y=n[g];if(y.valid&&!(y.valid[x>>3]>>(x&7)&1))break;let _=y.dictionary[y.indices[x]];if(!_&&_!==\"0\")break;b[d+h++]=_}if(h!==0)if(s)for(let g of r){b[0]=g.prefix;let y=b.slice(0,h+1),_=Io(g.sizeCol,x),{colorValue:C,colorLabel:v}=Do(e,g.colorCol,x);So(e,y,_,C,v,f+x,p)}else{let g=b.slice(0,h),y=Io(a,x),{colorValue:_,colorLabel:C}=Do(e,l,x);So(e,g,y,_,C,f+x,p)}}e.go=f+m}function bn(e){let t=e.r,n=t.value,o=t.size,i=t.firstChild,r=t.nextSibling,s=new Int32Array(128);s[0]=e.X,s[1]=0;let a=1;for(let l=0;l<t.count;l++)n[l]=0;for(;a>0;){a--;let l=s[a*2];if(s[a*2+1]===0){s[a*2+1]=1,a++;for(let m=i[l];m!==-1;m=r[m]){if((a+1)*2>s.length){let f=new Int32Array(s.length*2);f.set(s),s=f}s[a*2]=m,s[a*2+1]=0,a++}}else if(i[l]===-1){let m=o[l];n[l]=m>0?m:0}else{let m=0;for(let f=i[l];f!==-1;f=r[f])m+=n[f];n[l]=m}}if(e.le.length>1){let l=[];for(let f=1;f<e.le.length;f++)l.push(t.name[e.le[f]]);let u=e.X,m=!0;for(let f of l){let d=e.Gt.get(u)?.get(f);if(d===void 0){m=!1;break}u=d}if(m&&t.firstChild[u]!==-1){e.C=u,Bo(e,u);return}}e.C=e.X,e.le=[e.X]}function Bo(e,t){let n=[],o=t;for(;o!==-1;)n.unshift(o),o=e.r.parent[o];e.le=n}var Am=1,lr=14,sa=1,aa=4;function Po(e,t,n,o,i,r,s,a,l){if(e.x0[t]=Math.round(n),e.y0[t]=Math.round(o),e.x1[t]=Math.round(i),e.y1[t]=Math.round(r),e.firstChild[t]===-1||(i-n)*(r-o)<aa)return;let m=e.depth[t]-s,f=l&&m===1&&e.firstChild[t]!==-1,p=f?lr:sa,d=f?Am:sa,b=e.x0[t]+d,x=e.y0[t]+p,h=e.x1[t]-d,g=e.y1[t]-d;if(h<=b||g<=x)return;let y=0;for(let _=e.firstChild[t];_!==-1;_=e.nextSibling[_])e.value[_]>0&&(a[y++]=_);y!==0&&gn(e,a,0,y,b,x,h,g,s,a.subarray(y),l)}function gn(e,t,n,o,i,r,s,a,l,u,m){let f=o-n;if(f===0)return;if(f===1){Po(e,t[n],i,r,s,a,l,u,m);return}let p=0;for(let v=n;v<o;v++)p+=e.value[t[v]];let d=p/2,b=0,x=n+1,h=1/0;for(let v=n;v<o-1;v++){b+=e.value[t[v]];let A=Math.abs(b-d);A<h&&(h=A,x=v+1)}let g=0;for(let v=n;v<x;v++)g+=e.value[t[v]];let y=g/p,_=s-i,C=a-r;if(_>=C){let v=Math.round(i+_*y);gn(e,t,n,x,i,r,v,a,l,u,m),gn(e,t,x,o,v,r,s,a,l,u,m)}else{let v=Math.round(r+C*y);gn(e,t,n,x,i,r,s,v,l,u,m),gn(e,t,x,o,i,v,s,a,l,u,m)}}function la(e,t,n,o){e.ie=ur(e,t,n,o,0)}function ur(e,t,n,o,i){let r=e.r,s=r.x0,a=r.y0,l=r.x1,u=r.y1,m=r.depth,f=r.firstChild,p=r.nextSibling,d=r.value;(!e.$||e.$.length<r.count)&&(e.$=new Int32Array(r.count));let b=e.$,x=i,h=new Int32Array(128);h[0]=t;let g=1;for(;g>0;){g--;let y=h[g];if(d[y]<=0||(m[y]>=o&&(b[x++]=y),m[y]-o>=n))continue;let _=l[y]-s[y],C=u[y]-a[y];if(!(_*C<aa))for(let v=f[y];v!==-1;v=p[v]){if(g>=h.length){let A=new Int32Array(h.length*2);A.set(h),h=A}h[g++]=v}}return x}nn();vt();Ee();function Eo(e,t,n){return .299*e+.587*t+.114*n}function Lm(e,t){let n=Le(e,t);return[n[0],n[1],n[2]]}function hn(e,t,n,o){let i=e.r,r=i.colorValue[t];if(e.ye===\"numeric\"&&!isNaN(r)&&e.p>e.b)return Lm(n,rt(r,e.b,e.p));let s=e.f.get(i.colorLabel[t])??0;return o[s%o.length]??[0,0,0]}function Go(e,t,n,o,i){let r=hn(e,t,n,o),s=e.r.sizeSign[t]<0?i:1;return[r[0],r[1],r[2],s]}fe();function Wo(e,t,n,o,i,r,s){let a=Math.round(o*n),l=Math.round(i*n);(t.width!==a||t.height!==l)&&(t.width=a,t.height=l,e.Ct=!0);let u=t.getContext(\"2d\");if(u){if(e.Ct){e.ue?.close(),e.ue=null,e.Ct=!1;let m=++e.vn;r(u),createImageBitmap(t).then(f=>{e.vn===m?(e.ue?.close(),e.ue=f):f.close()})}else e.ue&&(u.clearRect(0,0,t.width,t.height),u.drawImage(e.ue,0,0));s&&(u.save(),u.scale(n,n),s(u),u.restore())}}bo();Ye();yo();function ua(e,t,n,o,i,r,s,a){if(n.length===0)return;let{Kn:l,wi:u,Ri:m}=t;e.font=`11px ${a}`;let f=16,p=8,d=0;for(let y of n){let _=e.measureText(y).width;_>d&&(d=_)}let b=d+p*2,x=n.length*f+p*2-4,h=o+12,g=i-x-8;h+b>r&&(h=o-b-12),h<0&&(h=4),g<0&&(g=i+12),g+x>s&&(g=s-x-4),e.fillStyle=l,e.strokeStyle=m,e.lineWidth=1,e.beginPath(),e.roundRect(h,g,b,x,4),e.fill(),e.stroke(),e.fillStyle=u,e.textAlign=\"left\",e.textBaseline=\"top\";for(let y=0;y<n.length;y++)e.fillText(n[y],h+p,g+p+y*f)}var ma=24,Tm=8,fa=12,ca=2,da=\" \\u203A \";function ko(e,t,n,o,i){e.Ve=[];let r=e.A().Kn;t.fillStyle=r,t.fillRect(0,0,n,ma),t.font=`11px ${o}`,t.textAlign=\"left\",t.textBaseline=\"middle\";let s=Tm,a=e.r;for(let l=0;l<e.le.length;l++){let u=e.le[l],m=l===e.le.length-1,f=a.name[u];t.fillStyle=i;let p=t.measureText(f).width;t.fillText(f,s,fa),e.Ve.push({nodeId:u,x0:s-ca,y0:0,x1:s+p+ca,y1:ma}),s+=p,m||(t.fillText(da,s,fa),s+=t.measureText(da).width)}}function No(e,t,n,o,i,r,s,a){let l=e.W.hoveredTarget===n?e.W.lines??[]:[];l.length!==0&&ua(t,e.A(),l,o,i,r,s,a)}function Uo(e,t,n,o,i,r,s,a=null){e.ye===\"series\"&&e.f.size>1?a?fn(t,a,e.f,n,i):xo(t,pa(r,s),e.f,n,i):e.ye===\"numeric\"&&e.b<e.p&&St(t,pa(r,s),{min:e.b,max:e.p,label:e.a},o,i,e.getColumnFormatter(e.a,\"value\"))}function pa(e,t){return new ne(e,t,{hasXLabel:!1,hasYLabel:!1,hasLegend:!0})}function ba(e,t){if(e.C===-1)return;let n=t.gl,o=t.cssWidth,i=t.cssHeight;if(o<=0||i<=0)return;let r=e.r,s=e.B.length>0&&e.G.facet_mode===\"grid\",a=e.le.length>1?28:0,u=(e.ye===\"series\"?e.f.size>1:e.ye===\"numeric\"&&e.b<e.p)?90:0,m=new Int32Array(Math.max(r.count,64));if(s)Rm(e,m,o,i,a,u);else{e.m=null;let b=r.depth[e.C];Po(r,e.C,0,a,o-u,i,b,m,e.ho),la(e,e.C,100,b),fr(e);let x=e.Ee,h=e.He;for(let g=0;g<e.ie;g++)x[g]=b,h[g]=e.C}if(!e.o){let b=j(t,\"treemap\",zn,Xn,[\"u_resolution\"],[\"a_position\",\"a_color\"]);e.o=b.program,e.F=b}let f=e.A(),p=f.H,d=de(f.ke,p,Math.max(1,e.f.size));if(e.j){let b=e.j.getContext(\"2d\");b&&b.clearRect(0,0,e.j.width,e.j.height)}e.Ct=!0,wm(e,n,p,d,f.Qn),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.o),n.uniform2f(e.F.u_resolution,o,i),n.bindBuffer(n.ARRAY_BUFFER,e.Wt),n.enableVertexAttribArray(e.F.a_position),n.vertexAttribPointer(e.F.a_position,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,e.kt),n.enableVertexAttribArray(e.F.a_color),n.vertexAttribPointer(e.F.a_color,4,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,e.Qo),e.pe(()=>kt(e))}function Rm(e,t,n,o,i,r){let s=e.r,a=[],l=[];for(let b=s.firstChild[e.X];b!==-1;b=s.nextSibling[b])s.value[b]<=0||(a.push(b),l.push(s.name[b]));let u=Math.max(1,o-i),m=Math.max(1,n-r),f=Re(l,{cssWidth:m,cssHeight:u,hasLegend:!1,xAxis:\"none\",yAxis:\"none\",gap:e.G.facet_padding});e.m=f,fr(e);let p=e.Ee,d=0;for(let b=0;b<a.length;b++){let x=a[b],h=f.cells[b];if(!h)continue;let g=s.name[x],y=e.st.get(g)??x,_=s.depth[y],C=h.layout.e;Po(s,y,C.x,C.y+i,C.x+C.width,C.y+i+C.height,_,t,e.ho);let v=ur(e,y,100,_,d);p.length<v&&fr(e);let A=e.Ee,T=e.He;for(let L=d;L<v;L++)A[L]=_,T[L]=y;d=v}e.ie=d}function fr(e){let t=e.$?.length??e.r.count;(!e.Ee||e.Ee.length<t)&&(e.Ee=new Int32Array(t)),(!e.He||e.He.length<t)&&(e.He=new Int32Array(t))}function wm(e,t,n,o,i){let r=e.r,s=e.$,a=e.ie,l=e.Ee,u=e.He,m=h=>l?l[h]:r.depth[e.C],f=h=>u?u[h]:e.C,p=0;for(let h=0;h<a;h++){let g=s[h];if(g===f(h))continue;let y=r.x1[g]-r.x0[g],_=r.y1[g]-r.y0[g];y<1||_<1||(r.firstChild[g]===-1?p++:r.depth[g]-m(h)===1&&(p+=2))}let d=new Float32Array(p*6*2),b=new Float32Array(p*6*4),x=0;for(let h=0;h<a;h++){let g=s[h];if(g===f(h))continue;let y=r.x0[g],_=r.y0[g],C=r.x1[g],v=r.y1[g],A=C-y,T=v-_;if(!(A<1||T<1)){if(r.firstChild[g]===-1){let L=Go(e,g,n,o,i);x=mr(d,b,x,y,_,C-1,v-1,L)}else if(r.depth[g]-m(h)===1){let R=[.25,.25,.25,1];x=mr(d,b,x,y,v-1,C,v,R),x=mr(d,b,x,C-1,_,C,v,R)}}}e.Qo=x,e.Wt||(e.Wt=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.Wt),t.bufferData(t.ARRAY_BUFFER,d.subarray(0,x*2),t.DYNAMIC_DRAW),e.kt||(e.kt=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.kt),t.bufferData(t.ARRAY_BUFFER,b.subarray(0,x*4),t.DYNAMIC_DRAW)}function mr(e,t,n,o,i,r,s,a){let l=n*2,u=n*4;e[l+0]=o,e[l+1]=i,e[l+2]=r,e[l+3]=i,e[l+4]=o,e[l+5]=s,e[l+6]=r,e[l+7]=i,e[l+8]=r,e[l+9]=s,e[l+10]=o,e[l+11]=s;for(let m=0;m<6;m++)t[u+m*4+0]=a[0],t[u+m*4+1]=a[1],t[u+m*4+2]=a[2],t[u+m*4+3]=a[3];return n+6}function kt(e){if(!e.c||e.C===-1)return;let t=e.t;if(!t)return;let{dpr:n,cssWidth:o,cssHeight:i}=t,r=e.re!==-1?e.re:e.E;Wo(e,e.c,n,o,i,s=>Mm(e,s,n,o,i),r!==-1?s=>{let a=e.A(),{fontFamily:l}=a,u=e.r;Fm(s,u,r);let m=e.$,f=e.ie,p=e.Ee,d=e.He;for(let b=0;b<f;b++){let x=m[b],h=d?d[b]:e.C;if(x===h||u.firstChild[x]===-1)continue;let g=u.x1[x]-u.x0[x],y=u.y1[x]-u.y0[x],_=p?p[b]:u.depth[e.C],C=u.depth[x]-_;C===1?Oo(s,u,x,g,y,a,!e.ho):C===2&&Oo(s,u,x,g,y,a,!0)}if(u.firstChild[r]===-1){let b=a.H,x=de(a.ke,b,Math.max(1,e.f.size)),h=u.x1[r]-u.x0[r],g=u.y1[r]-u.y0[r];ga(e,s,r,h,g,l,b,x,!0)}e.re===-1&&e.E!==-1&&Sm(e,s,e.E,o,i,l)}:null)}function Mm(e,t,n,o,i){let r=e.c;t.clearRect(0,0,r.width,r.height),t.save(),t.scale(n,n);let s=e.A(),{fontFamily:a,Le:l}=s,u=s.H,m=de(s.ke,u,Math.max(1,e.f.size)),f=e.r,p=e.$,d=e.ie,b=e.Ee,x=e.He;for(let h=0;h<d;h++){let g=p[h],y=x?x[h]:e.C;if(g===y||f.firstChild[g]!==-1)continue;let _=f.x1[g]-f.x0[g],C=f.y1[g]-f.y0[g];ga(e,t,g,_,C,a,u,m)}for(let h=0;h<d;h++){let g=p[h],y=x?x[h]:e.C;if(g===y||f.firstChild[g]===-1)continue;let _=f.x1[g]-f.x0[g],C=f.y1[g]-f.y0[g],v=b?b[h]:f.depth[e.C],A=f.depth[g]-v;A===1?Oo(t,f,g,_,C,s,!e.ho):A===2&&Oo(t,f,g,_,C,s,!0)}if(e.le.length>1&&ko(e,t,o,a,l),Uo(e,r,m,u,s,o,i),e.m){t.font=`11px ${a}`,t.fillStyle=l,t.textAlign=\"center\",t.textBaseline=\"top\";for(let h of e.m.cells){let g=h.layout.e;t.fillText(h.label,g.x+g.width/2,g.y-14)}}t.restore()}function ga(e,t,n,o,i,r,s,a,l=!1){if(o<30||i<14)return;let p=e.r,d=hn(e,n,s,a),b=Eo(d[0],d[1],d[2]),x=l?b>.5?\"rgba(0,0,0,0.85)\":\"rgba(255,255,255,0.9)\":b>.5?\"rgba(0,0,0,0.5)\":\"rgba(255,255,255,0.55)\",h=Math.min(11,Math.floor(i/2));if(h<7)return;t.font=`${h}px ${r}`;let g=o-8,y=h*1.3,_=Math.max(1,Math.floor((i-8)/y)),C=Ws(t,p.name[n],g,_);if(C.length===0)return;let v=C.length*y,A=p.y0[n]+(i-v)/2+y/2;t.fillStyle=x,t.textAlign=\"center\",t.textBaseline=\"middle\";let T=p.x0[n]+o/2;for(let L=0;L<C.length;L++)t.fillText(C[L],T,A+L*y)}function Oo(e,t,n,o,i,{fontFamily:r,Le:s,backgroundColor:a},l){let u=t.x0[n],m=t.y0[n],f=t.name[n];if(l){if(o<60||i<30)return;let p=12;e.font=`${p}px ${r}`;let d=f,b=o-16;if(e.measureText(d).width>b){for(;d.length>1;)if(d=d.slice(0,-1),e.measureText(d+\"\\u2026\").width<=b){d+=\"\\u2026\";break}}if(d.length<=3)return;e.save(),e.beginPath(),e.rect(u,m,o,i),e.clip();let h=u+o/2,g=m+i/2;e.textAlign=\"center\",e.textBaseline=\"middle\",e.lineWidth=2,e.strokeStyle=s,e.lineJoin=\"round\",e.strokeText(d,h,g),e.fillStyle=a,e.fillText(d,h,g),e.restore()}else{if(o<40||i<22)return;let p=11;e.font=`${p}px ${r}`;let d=f,b=o-10;if(e.measureText(d).width>b){for(;d.length>1;)if(d=d.slice(0,-1),e.measureText(d+\"\\u2026\").width<=b){d+=\"\\u2026\";break}}e.fillStyle=s,e.globalAlpha=.85,e.textAlign=\"left\",e.textBaseline=\"top\",e.fillText(d,u+5,m+4),e.globalAlpha=1}}function Fm(e,t,n){e.strokeStyle=\"rgba(255,255,255,0.9)\",e.lineWidth=2,e.strokeRect(t.x0[n],t.y0[n],t.x1[n]-t.x0[n],t.y1[n]-t.y0[n])}function Sm(e,t,n,o,i,r){let s=e.r,a=(s.x0[n]+s.x1[n])/2,l=(s.y0[n]+s.y1[n])/2;No(e,t,n,a,l,o,i,r)}async function ke(e,t,n){let o=e.r,i=oa(o,t),r=e.B.length>0&&e.G.facet_mode===\"grid\",s=r?i.slice(0,e.B.length):[],a=r?i.slice(e.B.length,e.B.length+e._.length):i.slice(0,e._.length),l=n===\"leaf\"?o.leafRowIdx[t]??null:null;await e.emitClickAndSelect({rowIdx:l!=null&&l>=0?l:null,columnName:e.ne,groupByValues:a,splitByValues:s})}async function dt(e,t){let n=e.r,o=[],i=[],r=t;for(;n.parent[r]!==-1;)i.push(n.name[r]),r=n.parent[r];i.reverse(),i.length>0?o.push(i.join(\" \\u203A \")):o.push(n.name[t]);let s=e.getColumnFormatter(e.ne,\"value\");if(o.push(`Value: ${s(n.value[t])}`),e.a&&!isNaN(n.colorValue[t])){let u=e.getColumnFormatter(e.a,\"value\");o.push(`${e.a}: ${u(n.colorValue[t])}`)}let a=n.leafRowIdx[t];if(n.firstChild[t]===-1&&a!==-1&&e.De){let u=await e.De.fetchRow(a);for(let[m,f]of u)f!=null&&(m===e.a&&!isNaN(n.colorValue[t])||(typeof f==\"number\"?o.push(`${m}: ${e.getColumnFormatter(m,\"value\")(f)}`):o.push(`${m}: ${f}`)))}return n.firstChild[t]!==-1&&o.push(`Children: ${n.childCount[t]}`),o}function Vo(e,t,n,o){e.T.dismiss(),e.re=t;let i=e.t?.cssWidth??0,r=e.t?.cssHeight??0;dt(e,t).then(s=>{e.re===t&&s.length!==0&&e.T.pin(s,{px:n.cx,py:n.cy},{cssWidth:i,cssHeight:r})}),e.E=-1,o()}function Ho(e){e.T.dismiss(),e.re=-1}function Yo(e,t,n){let o=e.r;if(e.B.length>0&&e.G.facet_mode===\"grid\"){let i=t;for(;i!==-1&&o.parent[i]!==e.X;)i=o.parent[i];i!==-1&&e.st.set(o.name[i],t),e.E=-1,n();return}e.C=t,Bo(e,t),e.E=-1,n()}function cr(e,t,n){let o=e.r,i=o.x0,r=o.y0,s=o.x1,a=o.y1,l=o.depth,u=o.firstChild,m=e.$,f=e.ie,p=e.Ee,d=e.He,b=-1,x=1/0,h=-1,g=1/0,y=-1;if(!m)return{leafId:-1,branchId:-1,inHeader:!1};for(let _=0;_<f;_++){let C=m[_],v=d?d[_]:e.C;if(C===v||!(t>=i[C]&&t<=s[C]&&n>=r[C]&&n<=a[C]))continue;let A=(s[C]-i[C])*(a[C]-r[C]);if(u[C]!==-1){A<g&&(g=A,h=C);let T=p?p[_]:l[e.C],L=l[C]-T;if(L===1&&n<=r[C]+lr&&(y=C),L===2){let R=s[C]-i[C],F=a[C]-r[C];if(R>=60&&F>=30){let I=r[C]+F/2,S=i[C]+R/2;Math.abs(n-I)<10&&Math.abs(t-S)<R*.4&&(y=C)}}}else A<x&&(x=A,b=C)}return y!==-1?{leafId:-1,branchId:y,inHeader:!0}:{leafId:b,branchId:h,inHeader:!1}}function ha(e,t,n){if(e.re!==-1)return;for(let a of e.Ve)if(t>=a.x0&&t<=a.x1&&n>=a.y0&&n<=a.y1){e.T.setCursor(\"pointer\"),e.E=-1,kt(e);return}let{leafId:o,branchId:i,inHeader:r}=cr(e,t,n),s=r?i:o!==-1?o:i;if(s!==e.E){if(e.E=s,e.T.setCursor(i!==-1?\"pointer\":\"default\"),s!==-1){let a=e.W.beginHover(s);dt(e,s).then(l=>{e.W.commitHover(a,l)&&kt(e)})}else e.W.clearHover();kt(e)}}function xa(e,t,n){if(e.re!==-1){xn(e),e.emitUnselect();return}for(let s of e.Ve)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e.C&&(zo(e,s.nodeId),e.emitUnselect());return}let{leafId:o,branchId:i,inHeader:r}=cr(e,t,n);i!==-1&&r?(zo(e,i),ke(e,i,\"branch\")):o!==-1?(Ca(e,o),ke(e,o,\"leaf\")):i!==-1&&(zo(e,i),ke(e,i,\"branch\"))}function ya(e,t,n){let o=e.re!==-1;xn(e),o&&e.emitUnselect();let{leafId:i,branchId:r}=cr(e,t,n),s=e.r,a=r;if(a===-1&&i!==-1){let l=s.parent[i];l!==e.C&&l!==-1&&(a=l)}a!==-1&&a!==e.C&&s.firstChild[a]!==-1&&(zo(e,a),ke(e,a,\"branch\"),i!==-1&&s.firstChild[i]===-1&&(Ca(e,i),ke(e,i,\"leaf\")))}function zo(e,t){Yo(e,t,()=>{e.t&&e.requestRender(e.t)})}function Ca(e,t){let n=e.r,o=(n.x0[t]+n.x1[t])/2,i=(n.y0[t]+n.y1[t])/2;Vo(e,t,{cx:o,cy:i},()=>kt(e))}function xn(e){Ho(e)}var Xo=class extends Et{constructor(){super(...arguments);c(this,\"o\",null);c(this,\"F\",null);c(this,\"Wt\",null);c(this,\"kt\",null);c(this,\"Qo\",0);c(this,\"E\",-1);c(this,\"re\",-1);c(this,\"Ve\",[]);c(this,\"ue\",null);c(this,\"Ct\",!0);c(this,\"vn\",0);c(this,\"st\",new Map);c(this,\"m\",null);c(this,\"ho\",!1);c(this,\"Ee\",null);c(this,\"He\",null)}tooltipCallbacks(){return{onHover:(n,o)=>ha(this,n,o),onLeave:()=>{this.E!==-1&&this.re===-1&&(this.E=-1,this.t&&this.requestRender(this.t))},onClickPre:(n,o)=>(xa(this,n,o),!0),onDblClick:(n,o)=>ya(this,n,o)}}async uploadAndRender(n,o,i,r){if(this.t=n,i===0){let s=this.I;if(this.ne=s[0]||Fo(o)||\"\",this.a=s[1]||\"\",!this.a)this.ye=\"empty\";else{let a=this.Ne[this.a],l=a===\"float\"||a===\"integer\"||a===\"date\"||a===\"datetime\";this.ye=l?\"numeric\":\"series\"}this.E=-1,this.re=-1,this.Ve=[],this.st.clear(),this.m=null,this.Ee=null,this.He=null,this.Qo=0,this.W.clearHover(),this.W.invalidatePin(),xn(this),this.ue?.close(),this.ue=null,this.Ct=!0,this.vn++,dn(this)}pn(this,o),bn(this),this.X!==-1&&await this.requestRender(n)}Dt(n){this.X!==-1&&(this.t=n,ba(this,n))}destroyInternal(){xn(this),this.ue?.close(),this.ue=null;let n=this.t?.gl;n&&(this.Wt&&n.deleteBuffer(this.Wt),this.kt&&n.deleteBuffer(this.kt)),this.Wt=null,this.kt=null,this.o=null,this.F=null,this.X=-1,this.C=-1,this.le=[],this.Gt.clear(),this.$=null,this.ie=0,this.Ve=[],this.st.clear(),this.m=null,this.Ee=null,this.He=null}};nn();Me();fe();var _a=4,yn=30;function Im(e,t){let n=0,o=e.depth[t],i=new Int32Array(128);i[0]=t;let r=1;for(;r>0;){r--;let s=i[r],a=e.depth[s]-o;a>n&&(n=a);for(let l=e.firstChild[s];l!==-1;l=e.nextSibling[l]){if(r>=i.length){let u=new Int32Array(i.length*2);u.set(i),i=u}i[r++]=l}}return n}function dr(e,t,n){let o=e.depth[t],i=Math.max(1,Im(e,t)),s=Math.max(0,n-yn)/i;e.a0[t]=0,e.a1[t]=2*Math.PI,e.r0[t]=0,e.r1[t]=yn,va(e,t,0,2*Math.PI,yn,s,o)}function va(e,t,n,o,i,r,s){let a=e.value[t];if(a<=0)return;let l=o-n,u=n;for(let m=e.firstChild[t];m!==-1;m=e.nextSibling[m]){let f=e.value[m];if(f<=0)continue;let p=f/a,d=u,b=u+l*p;u=b;let x=i,h=i+r;e.a0[m]=d,e.a1[m]=b,e.r0[m]=x,e.r1[m]=h;let g=b-d,y=(x+h)/2;g*y*r<_a||e.firstChild[m]!==-1&&va(e,m,d,b,h,r,s)}}function Aa(e,t){e.ie=pr(e,t,0)}function pr(e,t,n){let o=e.r,i=o.a0,r=o.a1,s=o.r0,a=o.r1,l=o.firstChild,u=o.nextSibling,m=o.value;(!e.$||e.$.length<o.count)&&(e.$=new Int32Array(o.count));let f=e.$,p=n,d=new Int32Array(128);d[0]=t;let b=1;for(;b>0;){b--;let x=d[b];if(m[x]<=0)continue;f[p++]=x;let h=r[x]-i[x],g=(s[x]+a[x])/2,y=h*g,_=a[x]-s[x];if(!(y*_<_a))for(let C=l[x];C!==-1;C=u[C]){if(b>=d.length){let v=new Int32Array(d.length*2);v.set(d),d=v}d[b++]=C}}return p}vt();var $o=32,Dm=28,Bm=90;function jo(e,t){if(e.u.length===0)return{centerX:e.lt,centerY:e.ut};let n=e.r;for(let o of e.u){let i=t;for(;i!==-1;){if(i===o.drillRoot)return{centerX:o.centerX,centerY:o.centerY};i=n.parent[i]}}return{centerX:e.lt,centerY:e.ut}}function Ra(e,t){if(e.C===-1)return;let n=t.gl,o=t.cssWidth,i=t.cssHeight;if(o<=0||i<=0)return;let r=e.B.length>0&&e.G.facet_mode===\"grid\",s=e.ye===\"series\"?e.f.size>1:e.ye===\"numeric\"&&e.b<e.p,a=!r&&e.le.length>1?Dm:0,l=s?Bm:0;if(r)Pm(e,o,i,l);else{e.m=null,e.u=[];let b=o-l,x=i-a;e.lt=b/2,e.ut=a+x/2,e.ei=Math.max(0,Math.min(b,x)/2-4),dr(e.r,e.C,e.ei),Aa(e,e.C)}Em(e,t);let u=e.A(),m=u.H,f=de(u.ke,m,Math.max(1,e.f.size));if(e.j){let b=e.j.getContext(\"2d\");b&&b.clearRect(0,0,e.j.width,e.j.height)}let p=t.dpr;e.Ct=!0,Gm(e,n,m,f,u.Qn,p),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.o);let d=e.F;if(n.uniform2f(d.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(d.u_border_px,u.Fi*p),e.u.length>0)for(let b of e.u)b.instanceCount!==0&&(n.uniform2f(d.u_center,b.centerX*p,b.centerY*p),La(e,n,t,b.instanceStart,b.instanceCount));else n.uniform2f(d.u_center,e.lt*p,e.ut*p),La(e,n,t,0,e.ti);e.pe(()=>qe(e))}function Pm(e,t,n,o){let i=e.r,r=[],s=[];for(let f=i.firstChild[e.X];f!==-1;f=i.nextSibling[f])i.value[f]<=0||(r.push(f),s.push(i.name[f]));let a=Math.max(1,t-o),l=Re(s,{cssWidth:a,cssHeight:n,hasLegend:!1,xAxis:\"none\",yAxis:\"none\",gap:e.G.facet_padding});e.m=l;let u=[],m=0;for(let f=0;f<r.length;f++){let p=r[f],d=l.cells[f];if(!d)continue;let b=i.name[p],x=e.st.get(b)??p,h=d.layout.e,g=h.x+h.width/2,y=h.y+h.height/2,_=Math.max(0,Math.min(h.width,h.height)/2-4);dr(i,x,_);let C=pr(e,x,m),v=m,A=C-m;u.push({label:b,centerX:g,centerY:y,maxRadius:_,drillRoot:x,instanceStart:v,instanceCount:A,nodeStart:v,nodeCount:A}),m=C}e.ie=m,e.u=u,u.length>0&&(e.lt=u[0].centerX,e.ut=u[0].centerY,e.ei=u[0].maxRadius)}function Em(e,t){if(e.o)return;let n=t.gl,o=j(t,\"sunburst-arc\",Hn,Yn,[\"u_center\",\"u_resolution\",\"u_border_px\"],[\"a_strip_t\",\"a_side\",\"a_angles\",\"a_radii\",\"a_color\"]);e.o=o.program,e.F=o;let i=new Float32Array(($o+1)*2*2);for(let r=0;r<=$o;r++){let s=r/$o,a=r*4;i[a+0]=s,i[a+1]=0,i[a+2]=s,i[a+3]=1}e.Qt=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.Qt),n.bufferData(n.ARRAY_BUFFER,i,n.STATIC_DRAW),e.en=n.createBuffer()}function Gm(e,t,n,o,i,r){let s=e.r,a=e.$,l=e.u.length>0,u=l?e.u.reduce((d,b)=>d+b.instanceCount,0):e.ie,m=new Float32Array(u*8),f=0,p=(d,b,x)=>{let h=f;for(let g=d;g<b;g++){let y=a[g];if(y===x)continue;let _=s.a0[y],C=s.a1[y],v=s.r0[y],A=s.r1[y];if(C<=_||A<=v)continue;let T=Go(e,y,n,o,i),L=f*8;m[L+0]=_,m[L+1]=C,m[L+2]=v*r,m[L+3]=A*r,m[L+4]=T[0],m[L+5]=T[1],m[L+6]=T[2],m[L+7]=T[3],f++}return{rangeStart:h,rangeCount:f-h}};if(l)for(let d of e.u){let b=d.instanceStart,x=b+d.instanceCount,{rangeStart:h,rangeCount:g}=p(b,x,d.drillRoot);d.instanceStart=h,d.instanceCount=g}else p(0,e.ie,e.C);e.ti=f,t.bindBuffer(t.ARRAY_BUFFER,e.en),t.bufferData(t.ARRAY_BUFFER,m.subarray(0,f*8),t.DYNAMIC_DRAW)}function La(e,t,n,o,i){if(i===0)return;let r=e.F;t.bindBuffer(t.ARRAY_BUFFER,e.Qt);let s=2*Float32Array.BYTES_PER_ELEMENT;t.enableVertexAttribArray(r.a_strip_t),t.vertexAttribPointer(r.a_strip_t,1,t.FLOAT,!1,s,0),t.enableVertexAttribArray(r.a_side),t.vertexAttribPointer(r.a_side,1,t.FLOAT,!1,s,Float32Array.BYTES_PER_ELEMENT);let a=J(n),{setDivisor:l}=a;l(r.a_strip_t,0),l(r.a_side,0),t.bindBuffer(t.ARRAY_BUFFER,e.en);let u=8*Float32Array.BYTES_PER_ELEMENT,m=Float32Array.BYTES_PER_ELEMENT,f=o*u;t.enableVertexAttribArray(r.a_angles),t.vertexAttribPointer(r.a_angles,2,t.FLOAT,!1,u,f),l(r.a_angles,1),t.enableVertexAttribArray(r.a_radii),t.vertexAttribPointer(r.a_radii,2,t.FLOAT,!1,u,f+2*m),l(r.a_radii,1),t.enableVertexAttribArray(r.a_color),t.vertexAttribPointer(r.a_color,4,t.FLOAT,!1,u,f+4*m),l(r.a_color,1),a.drawArraysInstanced(t.TRIANGLE_STRIP,0,2*($o+1),i),l(r.a_angles,0),l(r.a_radii,0),l(r.a_color,0)}function qe(e){if(!e.c||e.C===-1)return;let t=e.t;if(!t)return;let{dpr:n,cssWidth:o,cssHeight:i}=t;Wo(e,e.c,n,o,i,r=>Wm(e,r,n,o,i),e.E!==-1?r=>{km(r,e,e.E),Nm(e,r,e.E,o,i,e.A().fontFamily)}:null)}function Wm(e,t,n,o,i){let r=e.c;t.clearRect(0,0,r.width,r.height),t.save(),t.scale(n,n);let s=e.A(),{fontFamily:a,Le:l,Kn:u}=s,m=s.H,f=de(s.ke,m,Math.max(1,e.f.size)),p=e.r,d=e.$,b=e.ie,x=e.u.length>0;if(x)for(let g of e.u){let y=g.nodeStart+g.nodeCount;for(let _=g.nodeStart;_<y;_++){let C=d[_];C!==g.drillRoot&&Ta(e,t,C,a,m,f,g.centerX,g.centerY)}}else for(let g=0;g<b;g++){let y=d[g];y!==e.C&&Ta(e,t,y,a,m,f,e.lt,e.ut)}let h=Math.max(0,yn-s.Fi*.5);if(t.fillStyle=u,t.textAlign=\"center\",t.textBaseline=\"middle\",x){for(let g of e.u)if(t.beginPath(),t.fillStyle=u,t.arc(g.centerX,g.centerY,h,0,2*Math.PI),t.fill(),t.fillStyle=l,t.font=`11px ${a}`,t.fillText(p.name[g.drillRoot],g.centerX,g.centerY),e.m){let y=e.m.cells.find(_=>_.label===g.label);y?.titleRect&&(t.fillStyle=l,t.font=`11px ${a}`,t.textBaseline=\"middle\",t.fillText(g.label,y.titleRect.x+y.titleRect.width/2,y.titleRect.y+y.titleRect.height/2))}}else t.beginPath(),t.arc(e.lt,e.ut,h,0,2*Math.PI),t.fill(),t.fillStyle=l,t.font=`11px ${a}`,t.fillText(p.name[e.C],e.lt,e.ut);!x&&e.le.length>1&&ko(e,t,o,a,l),Uo(e,r,f,m,s,o,i,x?e.m?.legendRect??null:null),t.restore()}function Ta(e,t,n,o,i,r,s,a){let l=e.r,u=l.a0[n],m=l.a1[n],f=l.r0[n],p=l.r1[n],d=p-f,b=(f+p)/2,h=(m-u)*b;if(d<16||h<8)return;let g=Math.min(11,Math.floor(h*.7));if(g<7)return;t.font=`${g}px ${o}`;let y=l.name[n],_=d-4,C=y;if(t.measureText(C).width>_){for(;C.length>1;)if(C=C.slice(0,-1),t.measureText(C+\"\\u2026\").width<=_){C+=\"\\u2026\";break}}if(C.length<2)return;let v=(u+m)/2;t.save(),t.translate(s,a);let A=v,T=v>Math.PI/2&&v<3*Math.PI/2;e.Ui===\"upright\"&&T&&(A+=Math.PI),t.rotate(A);let L=hn(e,n,i,r),R=Eo(L[0],L[1],L[2]);t.fillStyle=R>.5?\"rgba(0,0,0,0.85)\":\"rgba(255,255,255,0.9)\",t.textAlign=\"center\",t.textBaseline=\"middle\";let F=e.Ui===\"upright\"&&T?-b:b;t.fillText(C,F,0),t.restore()}function km(e,t,n){let o=t.r,i=o.a0[n],r=o.a1[n],s=o.r0[n],a=o.r1[n],{centerX:l,centerY:u}=jo(t,n);e.strokeStyle=\"rgba(255,255,255,0.9)\",e.lineWidth=2,e.beginPath(),e.arc(l,u,a,i,r),e.arc(l,u,s,r,i,!0),e.closePath(),e.stroke()}function Nm(e,t,n,o,i,r){let s=e.r,a=(s.a0[n]+s.a1[n])/2,l=(s.r0[n]+s.r1[n])/2,{centerX:u,centerY:m}=jo(e,n),f=u+Math.cos(a)*l,p=m+Math.sin(a)*l;No(e,t,n,f,p,o,i,r)}function wa(e,t,n){if(e.u.length===0)return{centerX:e.lt,centerY:e.ut,drillRoot:e.C};for(let o of e.u){let i=t-o.centerX,r=n-o.centerY;if(!(Math.sqrt(i*i+r*r)>o.maxRadius+4))return{centerX:o.centerX,centerY:o.centerY,drillRoot:o.drillRoot}}return null}function Um(e,t,n){let o=e.r,i=t;for(;i!==-1;){if(i===n)return!0;i=o.parent[i]}return!1}function Ma(e,t,n){let o=wa(e,t,n);if(!o)return-1;let i=e.r,r=e.$,s=e.ie;if(!r)return-1;let a=t-o.centerX,l=n-o.centerY,u=Math.sqrt(a*a+l*l),m=Math.atan2(l,a);if(m<0&&(m+=2*Math.PI),u<i.r1[e.X]+.001&&o.drillRoot!==e.X)return o.drillRoot;let f=e.u.length>0;for(let p=0;p<s;p++){let d=r[p];if(d===o.drillRoot||f&&!Um(e,d,o.drillRoot))continue;let b=i.a0[d],x=i.a1[d],h=i.r0[d],g=i.r1[d];if(!(u<h||u>g)&&!(m<b||m>x))return d}return-1}function Fa(e,t,n){if(e.re!==-1)return;for(let r of e.Ve)if(t>=r.x0&&t<=r.x1&&n>=r.y0&&n<=r.y1){e.T.setCursor(\"pointer\"),e.E!==-1&&(e.E=-1,qe(e));return}let o=Ma(e,t,n),i=e.r;if(e.T.setCursor(o!==-1&&i.firstChild[o]!==-1?\"pointer\":\"default\"),o!==e.E){if(e.E=o,o!==-1){let r=e.W.beginHover(o);dt(e,o).then(s=>{e.W.commitHover(r,s)&&qe(e)})}else e.W.clearHover();qe(e)}}function Sa(e,t,n){if(e.re!==-1){Zo(e),e.emitUnselect();return}for(let s of e.Ve)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e.C&&(br(e,s.nodeId),e.emitUnselect());return}let o=e.r,i=wa(e,t,n);if(i){let s=t-i.centerX,a=n-i.centerY;if(Math.sqrt(s*s+a*a)<o.r1[e.X]+.001){let u=o.parent[i.drillRoot];if(u!==-1&&u!==e.X)br(e,u),e.emitUnselect();else if(e.u.length>0){let m=e.u.find(f=>f.drillRoot===i.drillRoot);m&&(e.st.delete(m.label),e.emitUnselect()),e.t&&e.requestRender(e.t)}return}}let r=Ma(e,t,n);r!==-1&&(o.firstChild[r]!==-1?(br(e,r),ke(e,r,\"branch\")):(Om(e,r),ke(e,r,\"leaf\")))}function br(e,t){Yo(e,t,()=>{e.t&&e.requestRender(e.t)})}function Om(e,t){let n=e.r,o=(n.a0[t]+n.a1[t])/2,i=(n.r0[t]+n.r1[t])/2,{centerX:r,centerY:s}=jo(e,t),a=r+Math.cos(o)*i,l=s+Math.sin(o)*i;Vo(e,t,{cx:a,cy:l},()=>qe(e))}function Zo(e){Ho(e)}var qo=class extends Et{constructor(){super(...arguments);c(this,\"o\",null);c(this,\"F\",null);c(this,\"Qt\",null);c(this,\"en\",null);c(this,\"ti\",0);c(this,\"Ui\",\"upright\");c(this,\"lt\",0);c(this,\"ut\",0);c(this,\"ei\",0);c(this,\"E\",-1);c(this,\"re\",-1);c(this,\"Ve\",[]);c(this,\"ue\",null);c(this,\"Ct\",!0);c(this,\"vn\",0);c(this,\"m\",null);c(this,\"st\",new Map);c(this,\"u\",[])}tooltipCallbacks(){return{onHover:(n,o)=>Fa(this,n,o),onLeave:()=>{this.E!==-1&&this.re===-1&&(this.E=-1,qe(this))},onClickPre:(n,o)=>(Sa(this,n,o),!0)}}async uploadAndRender(n,o,i,r){if(this.t=n,i===0){let s=this.I;if(this.ne=s[0]||Fo(o)||\"\",this.a=s[1]||\"\",!this.a)this.ye=\"empty\";else{let a=this.Ne[this.a],l=a===\"float\"||a===\"integer\"||a===\"date\"||a===\"datetime\";this.ye=l?\"numeric\":\"series\"}this.E=-1,this.re=-1,this.Ve=[],this.st.clear(),this.m=null,this.u=[],this.ti=0,this.W.clearHover(),this.W.invalidatePin(),Zo(this),this.ue?.close(),this.ue=null,this.Ct=!0,this.vn++,dn(this)}pn(this,o),bn(this),this.X!==-1&&await this.requestRender(n)}Dt(n){this.X!==-1&&(this.t=n,Ra(this,n))}destroyInternal(){Zo(this),this.ue?.close(),this.ue=null;let n=this.t?.gl;n&&(this.Qt&&n.deleteBuffer(this.Qt),this.en&&n.deleteBuffer(this.en)),this.Qt=null,this.en=null,this.o=null,this.F=null,this.X=-1,this.C=-1,this.le=[],this.Gt.clear(),this.$=null,this.ie=0,this.Ve=[],this.m=null,this.st.clear(),this.u=[]}};Jt();var Nt=class extends Te{constructor(){super(...arguments);c(this,\"we\",[]);c(this,\"ee\",0);c(this,\"mt\",0);c(this,\"o\",null);c(this,\"k\",null);c(this,\"l\",null);c(this,\"he\",null);c(this,\"xe\",null);c(this,\"Re\",null);c(this,\"io\",!0)}getZoomConfig(){return{lockAxis:\"y\"}}};Qt();function Ko(e,t=.5,n=.1){let o=t/Math.max(1,e),i=o*(1-n)/2;return{slotWidth:o,halfWidth:i}}function Ia(e,t,n=\"bar\"){let o=t?.[e]?.chart_type?.toLowerCase?.();return o===\"bar\"||o===\"line\"||o===\"scatter\"||o===\"area\"?o:n}function Da(e,t,n){let o=n?.[e]?.stack;return typeof o==\"boolean\"?o:t===\"bar\"||t===\"area\"}function gr(e,t){return t?.[e]?.alt_axis===!0}function Ba(e,t,n){if(t!==\"line\"&&t!==\"area\")return\"skip\";let o=n?.[e]?.interpolate;return o===void 0||t===\"area\"?\"solid\":o}var Pa=50,pt=0,Jo=1;function Qo(){return{count:0,catIdx:new Int32Array(0),seriesId:new Int32Array(0),axis:new Uint8Array(0),chartType:new Uint8Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),y0:new Float64Array(0),y1:new Float64Array(0)}}function Vm(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),seriesId:new Int32Array(t),axis:new Uint8Array(t),chartType:new Uint8Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),y0:new Float64Array(t),y1:new Float64Array(t)}}function Cn(e,t,n,o,i){let r=e.seriesId[t],s=e.catIdx[t];return{catIdx:s,aggIdx:Math.floor(r/n),splitIdx:r%n,seriesId:r,xCenter:e.xCenter[t],halfWidth:e.halfWidth[t],y0:e.y0[t],y1:e.y1[t],value:o[s*i+r],axis:e.axis[t],chartType:e.chartType[t]===pt?\"bar\":\"area\"}}function Ea(e,t){return e&&e.length>=t?e:new Float64Array(Math.max(t,e?.length??0))}function Ga(e,t){e[t>>3]|=1<<(t&7)}function Wa(e){let{columns:t,numRows:n,columnSlots:o,groupBy:i,splitBy:r,groupByTypes:s,columnsConfig:a,defaultChartType:l,autoAltYAxis:u,bandInnerFrac:m,barInnerPad:f,includeZero:p,facetSplits:d,scratchBars:b,scratchPosStack:x,scratchNegStack:h}=e,g=Gt(i,s),y={aggregates:[],splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:g,numericCategoryDomain:null,categoryPositions:null,series:[],bars:Qo(),posStack:x??null,negStack:h??null,samples:new Float32Array(0),sampleValid:new Uint8Array(0),leftDomain:{min:0,max:0},rightDomain:null,hasRightAxis:!1,leftValueAxisMode:\"numeric\",rightValueAxisMode:null,leftValueCategoryDomain:null,rightValueCategoryDomain:null},_=o.filter(w=>!!w);if(_.length===0)return y;let C=[];if(r.length>0){for(let w of He(t,[],_))w.colNames.size>0&&C.push(w.prefix);C.length===0&&C.push(\"\")}else C.push(\"\");let v=i.map(w=>s[w]??\"string\"),{rowPaths:A,numCategories:T,rowOffset:L}=Wt(t,n,i.length,v);if(T===0)return{...y,aggregates:_,splitPrefixes:C,rowPaths:A,rowOffset:L};let R=[],F=_.length,I=C.length;for(let w=0;w<F;w++)for(let P=0;P<I;P++){let E=_[w],U=C[P],z=U===\"\"?E:`${U}${F>1?` | ${E}`:\"\"}`,H=Ia(E,a,l),Z=Da(E,H,a),be=Ba(E,H,a);R.push({seriesId:w*I+P,aggIdx:w,splitIdx:P,aggName:E,splitKey:U,label:z,color:[.5,.5,.5],axis:0,chartType:H,stack:Z,start:-1,end:-1,interpolateMode:be})}let S=[];for(let w=0;w<F;w++)S.push(p?{min:0,max:0}:{min:1/0,max:-1/0});let D=T,B=R.length,N=d?D*F*I:D*F,k=Ea(x??null,N),Y=Ea(h??null,N);k.fill(0,0,N),Y.fill(0,0,N);let W=new Float32Array(D*B),V=new Uint8Array(D*B+7>>3),O=null,X=null,q=1;if(g.mode===\"numeric\"&&D>0){let w=t.get(\"__ROW_PATH_0__\"),P=ct(w?.values,D,L,i[0]??\"\",g.numericType===\"date\"||g.numericType===\"datetime\");P&&(O=P.categoryPositions,X=P.numericCategoryDomain,q=P.numericCategoryDomain.bandWidth)}let le=Ko(F,m,f),Fe=le.slotWidth*q,_e=le.halfWidth*q,ve=new Float64Array(F),et=(F-1)/2;for(let w=0;w<F;w++)ve[w]=(w-et)*Fe;let zt=new Array(F*I),Xt=new Array(F*I);for(let w=0;w<F;w++){let P=_[w];for(let E=0;E<I;E++){let U=C[E],z=U===\"\"?P:`${U}|${P}`,H=t.get(z),Z=w*I+E;zt[Z]=H?.values??null,Xt[Z]=H?.valid??null}}let $t=new Array(F),ge=new Array(F),se=!1;for(let w=0;w<F;w++){let P=_[w],E=C[0],U=E===\"\"?P:`${E}|${P}`;$t[w]=t.get(U)?.type===\"string\",ge[w]=gr(P,a)?1:0,$t[w]&&(se=!0)}let Q=[],oe=[],Se=[],Ie=[];for(let w=0;w<F;w++){let P=_[w];for(let E=0;E<I;E++){let U=C[E],z=U===\"\"?P:`${U}|${P}`,H=w*I+E,Z={name:z,type:$t[w]?\"string\":\"numeric\",data:t.get(z)};ge[w]===0?(Q.push(Z),Se.push(H)):(oe.push(Z),Ie.push(H))}}let Xr=Q.map(w=>w.name).filter((w,P,E)=>E.indexOf(w)===P).join(\", \"),Ai=oe.map(w=>w.name).filter((w,P,E)=>E.indexOf(w)===P).join(\", \"),De=Q.length>0?ar(Q,n,L,Xr):null,K=oe.length>0?ar(oe,n,L,Ai):null,bt=new Array(F*I).fill(null);if(De)for(let w=0;w<Se.length;w++)bt[Se[w]]=De.perColumnSlots[w];if(K)for(let w=0;w<Ie.length;w++)bt[Ie[w]]=K.perColumnSlots[w];let Pl=D*F*I,$=Vm(b??null,Pl),ee=0;for(let w=0;w<D;w++){let P=w+L;for(let E=0;E<F;E++)for(let U=0;U<I;U++){let z=E*I+U,H=bt[z];if(H){let ae=E*I+U,he=w*B+ae;W[he]=H[w],Ga(V,he);continue}let Z=zt[z];if(!Z)continue;let be=Xt[z];if(be&&!(be[P>>3]>>(P&7)&1))continue;let te=Z[P];if(!isFinite(te))continue;let ht=E*I+U,nt=w*B+ht;W[nt]=te,Ga(V,nt)}}for(let w=0;w<B;w++){let P=-1,E=-1;for(let U=0;U<D;U++){let z=U*B+w;V[z>>3]>>(z&7)&1&&(P===-1&&(P=U),E=U)}R[w].start=P,R[w].end=E}for(let w=0;w<B;w++){let P=R[w];if(!(P.start<0)&&P.interpolateMode!==\"skip\"){if(P.chartType===\"line\"){let E=P.start;for(let U=P.start+1;U<=P.end;U++){let z=U*B+w;if(V[z>>3]>>(z&7)&1){if(U-E>1){let Z=E*B+w,be=W[Z],te=W[z],ht=O?O[E]:E,ae=(O?O[U]:U)-ht;for(let he=1;he<U-E;he++){let ce=E+he,xe=O?O[ce]:ce,Ol=ae===0?0:(xe-ht)/ae;W[ce*B+w]=be+(te-be)*Ol}}E=U}}}else if(P.chartType===\"area\"){for(let E=0;E<P.start;E++)W[E*B+w]=0;for(let E=P.end+1;E<D;E++)W[E*B+w]=0;P.start=0,P.end=D-1}}}for(let w=0;w<D;w++){let P=O?O[w]:w;for(let E=0;E<F;E++){let U=ve[E],z=P+U,H=S[E];for(let Z=0;Z<I;Z++){let be=E*I+Z,te=R[be];if(w<te.start||w>te.end)continue;let ht=te.chartType===\"line\"||te.chartType===\"area\"&&te.interpolateMode!==\"skip\",nt=w*B+be;if(!ht&&!(V[nt>>3]>>(nt&7)&1))continue;let ae=W[nt];if((te.chartType===\"bar\"||te.chartType===\"area\")&&te.stack){if(ae===0&&(te.chartType!==\"area\"||te.interpolateMode===\"skip\"))continue;let he=d?(w*F+E)*I+Z:w*F+E,ce,xe;ae>=0?(ce=k[he],xe=ce+ae,k[he]=xe):(ce=Y[he],xe=ce+ae,Y[he]=xe),ce<H.min&&(H.min=ce),xe<H.min&&(H.min=xe),ce>H.max&&(H.max=ce),xe>H.max&&(H.max=xe),$.catIdx[ee]=w,$.seriesId[ee]=be,$.axis[ee]=0,$.chartType[ee]=te.chartType===\"bar\"?pt:Jo,$.xCenter[ee]=z,$.halfWidth[ee]=_e,$.y0[ee]=ce,$.y1[ee]=xe,ee++}else if(ae<H.min&&(H.min=ae),ae>H.max&&(H.max=ae),p&&(0<H.min&&(H.min=0),0>H.max&&(H.max=0)),te.chartType===\"bar\"||te.chartType===\"area\"){if(ae===0)continue;$.catIdx[ee]=w,$.seriesId[ee]=be,$.axis[ee]=0,$.chartType[ee]=te.chartType===\"bar\"?pt:Jo,$.xCenter[ee]=z,$.halfWidth[ee]=_e,$.y0[ee]=0,$.y1[ee]=ae,ee++}}}}$.count=ee;let gt=!1;if(u&&F>=2&&!se){let w=new Array(F),P=0,E=1/0;for(let U=0;U<F;U++){let z=S[U],H=Math.max(Math.abs(z.min),Math.abs(z.max),1e-12);w[U]=H,H>P&&(P=H),H<E&&(E=H)}if(P/E>Pa){let U=P/Math.sqrt(Pa);for(let z=0;z<F;z++)if(w[z]<U)for(let Z of R)Z.aggIdx===z&&(Z.axis=1);for(let z=0;z<$.count;z++)$.axis[z]=R[$.seriesId[z]].axis;gt=R.some(z=>z.axis===1)}}let $r=!1;for(let w=0;w<F;w++)if(gr(_[w],a))for(let P of R)P.aggIdx===w&&(P.axis=1,$r=!0);if($r){for(let w=0;w<$.count;w++)$.axis[w]=R[$.seriesId[w]].axis;gt=!0}let Be=p?{min:0,max:0}:{min:1/0,max:-1/0},tt=p?{min:0,max:0}:{min:1/0,max:-1/0};for(let w=0;w<$.count;w++){let P=$.axis[w]===0?Be:tt,E=$.y0[w],U=$.y1[w];E<P.min&&(P.min=E),U<P.min&&(P.min=U),E>P.max&&(P.max=E),U>P.max&&(P.max=U)}for(let w=0;w<B;w++){let P=R[w];if(P.stack&&(P.chartType===\"bar\"||P.chartType===\"area\")||P.start<0)continue;let E=P.chartType===\"line\"||P.chartType===\"area\"&&P.interpolateMode!==\"skip\",U=P.axis===0?Be:tt;for(let z=P.start;z<=P.end;z++){let H=z*B+w;if(!E&&!(V[H>>3]>>(H&7)&1))continue;let Z=W[H];Z<U.min&&(U.min=Z),Z>U.max&&(U.max=Z)}}(!isFinite(Be.min)||!isFinite(Be.max)||Be.min===0&&Be.max===0)&&(Be.min=0,Be.max=1);let El=!isFinite(tt.min)||!isFinite(tt.max)||tt.min===0&&tt.max===0,Gl=gt?El?{min:0,max:1}:tt:null,Wl=De?\"category\":\"numeric\",kl=gt?K?\"category\":\"numeric\":null,Nl=De&&De.domain.numRows>0?{min:0,max:Math.max(0,De.domain.numRows-1)}:Be,Ul=K&&K.domain.numRows>0&&gt?{min:0,max:Math.max(0,K.domain.numRows-1)}:Gl;return{aggregates:_,splitPrefixes:C,rowPaths:A,numCategories:T,rowOffset:L,axisMode:g,numericCategoryDomain:X,categoryPositions:O,series:R,bars:$,posStack:k,negStack:Y,samples:W,sampleValid:V,leftDomain:Nl,rightDomain:Ul,hasRightAxis:gt,leftValueAxisMode:Wl,rightValueAxisMode:kl,leftValueCategoryDomain:De?.domain??null,rightValueCategoryDomain:K?.domain??null}}Ye();on();Ct();Me();var hr=pt;function ka(e,t,n,o){let i=o?.start??0,r=o?.count??e.An;if(e.An===0||r===0)return;let s=e.F,a=J(n),{setDivisor:l}=a;t.bindBuffer(t.ARRAY_BUFFER,e.k),t.enableVertexAttribArray(s.a_corner),t.vertexAttribPointer(s.a_corner,2,t.FLOAT,!1,0,0),l(s.a_corner,0),Ze(n,a,s.a_x_center,\"bar_x\",1,i)&&Ze(n,a,s.a_half_width,\"bar_hw\",1,i)&&Ze(n,a,s.a_y0,\"bar_y0\",1,i)&&Ze(n,a,s.a_y1,\"bar_y1\",1,i)&&Ze(n,a,s.a_color,\"bar_color\",3,i)&&Ze(n,a,s.a_series_id,\"bar_sid\",1,i)&&Ze(n,a,s.a_axis,\"bar_axis\",1,i)&&a.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,r),l(s.a_x_center,0),l(s.a_half_width,0),l(s.a_y0,0),l(s.a_y1,0),l(s.a_color,0),l(s.a_series_id,0),l(s.a_axis,0)}var ei=10;function Ut(e){return e.Me>=0?Cn(e.me,e.Me,e.fe.length,e.je,e.s.length):e.Fe}function xr(e,t,n){if(!e.l)return;let o=e.l,i;if(e.m){let C=e.m.cells,v=-1;for(let A=0;A<C.length;A++){let T=C[A].layout.e;if(t>=T.x&&t<=T.x+T.width&&n>=T.y&&n<=T.y+T.height){v=A;break}}if(v<0){Na(e);return}o=C[v].layout,i=v}let r=o.e;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){Na(e);return}let s=o.Y,a=o.J,l=o.q,u=o.Q,m,f,p,d;if(e.Ze){let C=s,v=a,A=Math.min(l,u),T=Math.max(l,u),L=C+(t-r.x)/r.width*(v-C);m=A+(n-r.y)/r.height*(T-A),f=L,p=r.height/(T-A),d=r.width/(v-C)}else m=s+(t-r.x)/r.width*(a-s),f=u-(n-r.y)/r.height*(u-l),p=r.width/(a-s),d=r.height/(u-l);let b=e.tn&&e.te&&!e.Ze?e.te.max-(n-r.y)/r.height*(e.te.max-e.te.min):f,x=e.tn&&e.te&&!e.Ze?r.height/(e.te.max-e.te.min):d,h=-1,g=null,y=e.Nt,_=y.length<=1;for(let C=y.length-1;C>=0;C--){let v=y[C],A=_?void 0:{start:v.aggStart,end:v.aggEnd};switch(v.chartType){case\"scatter\":case\"line\":g=Ym(e,v.chartType,m,f,b,p,d,x,i,A);break;case\"bar\":h=Hm(e,m,f,b,i,A);break;case\"area\":{let T=zm(e,m,f,b,i,A);T&&(T.idx>=0?h=T.idx:g=T.bar);break}}if(h>=0||g)break}Xm(e,h,g)}function Hm(e,t,n,o,i,r){let s=e.me,a=s.chartType,l=s.seriesId,u=s.xCenter,m=s.halfWidth,f=s.y0,p=s.y1,d=s.axis,b=e.K,x=Math.max(1,e.fe.length);for(let h=0;h<s.count;h++){if(a[h]!==pt||b.has(l[h])||i!==void 0&&l[h]%x!==i)continue;if(r!==void 0){let L=Math.floor(l[h]/x);if(L<r.start||L>r.end)continue}let g=u[h],y=m[h];if(t<g-y||t>g+y)continue;let _=d[h]===0?n:o,C=f[h],v=p[h],A=C<v?C:v,T=C<v?v:C;if(_>=A&&_<=T)return h}return-1}function Ym(e,t,n,o,i,r,s,a,l,u){let m=e.ee,f=e.s.length;if(m===0||f===0)return null;let p=e.je,d=e.Ut,x=ei*ei,h=null,g=e.qe;for(let y of e.s){if(y.chartType!==t||e.K.has(y.seriesId)||l!==void 0&&y.splitIdx!==l||u!==void 0&&(y.aggIdx<u.start||y.aggIdx>u.end))continue;let _=y.axis===1?i:o,C=y.axis===1?a:s,v=g?0:Math.max(0,Math.floor(n-ei/r)),A=g?m-1:Math.min(m-1,Math.ceil(n+ei/r));for(let T=v;T<=A;T++){let L=T*f+y.seriesId;if(!(d[L>>3]>>(L&7)&1))continue;let R=p[L],F=g?g[T]:T,I=(F-n)*r,S=(R-_)*C,D=I*I+S*S;D<x&&(x=D,h={catIdx:T,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:F,halfWidth:0,y0:0,y1:R,value:R,axis:y.axis,chartType:\"bar\"})}}return h}function zm(e,t,n,o,i,r){let s=Math.round(t);if(s<0||s>=e.ee||Math.abs(t-s)>.5)return null;let a=e.s.length,l=e.je,u=e.Ut,m=e.me,f=m.chartType,p=m.catIdx,d=m.seriesId,b=m.axis,x=m.y0,h=m.y1,g=e.fe.length;for(let y=0;y<m.count;y++){if(f[y]!==Jo||p[y]!==s||e.K.has(d[y])||i!==void 0&&d[y]%g!==i)continue;if(r!==void 0){let L=Math.floor(d[y]/Math.max(1,g));if(L<r.start||L>r.end)continue}let _=b[y]===0?n:o,C=x[y],v=h[y],A=C<v?C:v,T=C<v?v:C;if(_>=A&&_<=T)return{idx:y,bar:null}}for(let y of e.s){if(y.chartType!==\"area\"||y.stack||e.K.has(y.seriesId)||i!==void 0&&y.splitIdx!==i||r!==void 0&&(y.aggIdx<r.start||y.aggIdx>r.end))continue;let _=s*a+y.seriesId;if(!(u[_>>3]>>(_&7)&1))continue;let C=l[_],v=y.axis===1?o:n,A=Math.min(0,C),T=Math.max(0,C);if(v>=A&&v<=T)return{idx:-1,bar:{catIdx:s,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:s,halfWidth:.5,y0:0,y1:C,value:C,axis:y.axis,chartType:\"area\"}}}return null}function Na(e){(e.Me!==-1||e.Fe!==null)&&(e.Me=-1,e.Fe=null,e.t&&e.requestRender(e.t))}function Xm(e,t,n){let o=e.Me===t,i=(e.Fe?.seriesId??-1)===(n?.seriesId??-1)&&(e.Fe?.catIdx??-1)===(n?.catIdx??-1);o&&i||(e.Me=t,e.Fe=n,e.t&&e.requestRender(e.t))}function Ua(e,t,n){if(e.nn.length===0)return!1;for(let o of e.nn){let i=o.rect;if(t>=i.x&&t<=i.x+i.width&&n>=i.y&&n<=i.y+i.height){let r=o.seriesIds.some(s=>!e.K.has(s));for(let s of o.seriesIds)r?e.K.add(s):e.K.delete(s);return e._t=null,e.xo=!1,e.yo=null,e.t&&(ti(e,e.t),ni(e,e.t),e.requestRender(e.t)),!0}}return!1}function yr(e,t){let n=[],o=e.s[t.seriesId],i=$m(e,t.catIdx);i&&n.push(i);let r=e.getColumnFormatter(o.aggName,\"value\");return n.push(`${o.aggName}: ${r(t.value)}`),o.splitKey&&n.push(`Split: ${o.splitKey}`),t.y0!==0&&(n.push(`Base: ${r(t.y0)}`),n.push(`Top: ${r(t.y1)}`)),n}function $m(e,t){if(e.Ke===\"numeric\"&&e.D){let o=e.me,i=null;for(let s=0;s<o.count;s++)if(o.catIdx[s]===t){i=o.xCenter[s];break}if(i==null)return\"\";let r=e._[0];return e.getColumnFormatter(r,\"value\")(i)}if(e.we.length===0)return\"\";let n=[];for(let o of e.we){let i=o.labels[t];i!=null&&i!==\"\"&&n.push(i)}return n.join(\" / \")}function Oa(e,t){t<0||t>=e.me.count||(e.ni=t,Ha(e,Cn(e.me,t,e.fe.length,e.je,e.s.length)))}function Va(e,t){e.ni=-1,Ha(e,t)}function Ha(e,t){if(e.T.dismiss(),!e.l)return;let n=Cr(e,t);if(!n)return;let i=(e.s[t.seriesId]?.chartType??\"bar\")===\"bar\"?(t.y0+t.y1)/2:t.y1,r=t.axis===0?e.Ze?n.P(i,t.xCenter):n.P(t.xCenter,i):_r(e,t.xCenter,i,n),s=yr(e,t);s.length!==0&&(e.T.pin(s,r,n),e.Me=-1,e.Fe=null,e.t&&e.requestRender(e.t))}Ae();Yi();Ae();ut();Ft();po();function Ya(e,t,n){if(n)return n;if(!e.isDate)return me;let o=t.length>1?t[1]-t[0]:0;return i=>ye(i,o)}function vr(e,t,n,o,i,r,s){let{Le:a,fontFamily:l}=r,{e:u}=t,m=i===\"bottom\"?u.y+u.height:u.y;e.fillStyle=a,e.font=`11px ${l}`,e.lineWidth=1,fo(e,u,o,m,i,f=>t.P(f,0).px,Ya(n,o,s)),e.font=`13px ${l}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(n.label,u.x+u.width/2,i===\"bottom\"?t.cssHeight-2:10)}function Ar(e,t,n,o,i,r,s){let{Le:a,fontFamily:l}=r,{e:u}=t,m=i===\"left\"?u.x:u.x+u.width;e.fillStyle=a,e.font=`11px ${l}`,e.lineWidth=1,co(e,u,o,m,i,f=>t.P(0,f).py,Ya(n,o,s)),e.font=`13px ${l}`,e.save(),i===\"left\"?(e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2)):(e.translate(t.cssWidth-10,u.y+u.height/2),e.rotate(Math.PI/2)),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(n.label,0,0),e.restore()}function oi(e,t,n,o,i,r){vr(e,t,n,o,\"bottom\",i,r)}function ii(e,t,n,o,i,r){Ar(e,t,n,o,\"left\",i,r)}function ri(e,t,n,o,i,r,s,a=!1,l={}){let u=ue(e,o,r);if(!u)return;let{e:m}=o;if(u.strokeStyle=i.Jn,u.lineWidth=1,u.beginPath(),u.moveTo(m.x,m.y),u.lineTo(m.x,m.y+m.height),u.lineTo(m.x+m.width,m.y+m.height),s&&(a?(u.moveTo(m.x,m.y),u.lineTo(m.x+m.width,m.y)):(u.moveTo(m.x+m.width,m.y),u.lineTo(m.x+m.width,m.y+m.height))),u.stroke(),a){if(t.mode===\"category\"?we(u,o,t.domain,i):ii(u,o,t.domain,t.ticks,i,l.category),n.mode===\"category\"?pe(u,o,n.domain,i):vr(u,o,n.domain,n.ticks,\"bottom\",i,l.value),s)if(s.mode===\"category\")pe(u,o,s.domain,i);else{let f=o.Y,p=o.J;o.Y=s.domain.min,o.J=s.domain.max,vr(u,o,s.domain,s.ticks,\"top\",i,l.alt),o.Y=f,o.J=p}}else if(t.mode===\"category\"?pe(u,o,t.domain,i):oi(u,o,t.domain,t.ticks,i,l.category),n.mode===\"category\"?we(u,o,n.domain,i):Ar(u,o,n.domain,n.ticks,\"left\",i,l.value),s)if(s.mode===\"category\")we(u,o,s.domain,i);else{let f=o.q,p=o.Q;o.q=s.domain.min,o.Q=s.domain.max,Ar(u,o,s.domain,s.ticks,\"right\",i,l.alt),o.q=f,o.Q=p}}function si(e,t,n,o,i,r=!1){let s=ue(e,t,i);s&&(s.strokeStyle=o.un,s.lineWidth=1,r?Lt(s,t.e,n,a=>t.P(a,0).px):Tt(s,t.e,n,a=>t.P(0,a).py))}Ft();vt();mo();ut();po();var Ke=null;function za(e){if(Ke&&Ke.xCenters.length>=e&&Ke.colors.length>=e*3)return Ke;let t=Math.max(e,Ke?.xCenters.length??0);return Ke={xCenters:new Float32Array(t),halfWidths:new Float32Array(t),y0s:new Float32Array(t),y1s:new Float32Array(t),seriesIds:new Float32Array(t),axes:new Float32Array(t),colors:new Float32Array(t*3)},Ke}function ti(e,t){let n=e.me,o=n.count,i=e.fe.length,r=e.on&&i>0,s=0;if(e.Co=null,e.Ln=null,e.Tn=null,o>0){let l=za(o);(!e.Rn||e.Rn.length<o)&&(e.Rn=new Int32Array(o));let u=e.Rn,m=e.se,f=e.s,p=e.K,d=n.chartType,b=n.seriesId,x=n.xCenter,h=n.halfWidth,g=n.y0,y=n.y1,_=n.axis,C=Math.max(1,e.vt.length),v=r?S=>S%i*C+Math.floor(S/i):S=>i>0?Math.floor(S/i):S,A=r?i*C:C,T=new Array(A).fill(0);for(let S=0;S<o;S++)d[S]!==hr||p.has(b[S])||T[v(b[S])]++;let L=[],R=new Int32Array(A),F=0;for(let S=0;S<A;S++)L.push({start:F,count:T[S]}),R[S]=F,F+=T[S];r?(e.Tn=null,e.Ln=Array.from({length:i},(S,D)=>L.slice(D*C,(D+1)*C)),e.Co=Array.from({length:i},(S,D)=>{let B=L[D*C],N=L[(D+1)*C-1];return{start:B.start,count:N.start+N.count-B.start}})):(e.Tn=L,e.Ln=null);let I=S=>R[v(S)]++;for(let S=0;S<o;S++){if(d[S]!==hr)continue;let D=b[S];if(p.has(D))continue;let B=I(D);l.xCenters[B]=x[S]-m,l.halfWidths[B]=h[S],l.y0s[B]=g[S],l.y1s[B]=y[S],l.seriesIds[B]=D,l.axes[B]=_[S];let N=f[D].color;l.colors[B*3]=N[0],l.colors[B*3+1]=N[1],l.colors[B*3+2]=N[2],u[B]=S,s++}}else r&&(e.Co=Array.from({length:i},()=>({start:0,count:0})));if(e.An=s,s===0){e.Ye=null;return}let a=Ke;t.v.ensureCapacity(s),t.v.upload(\"bar_x\",a.xCenters.subarray(0,s),0,1),t.v.upload(\"bar_hw\",a.halfWidths.subarray(0,s),0,1),t.v.upload(\"bar_y0\",a.y0s.subarray(0,s),0,1),t.v.upload(\"bar_y1\",a.y1s.subarray(0,s),0,1),t.v.upload(\"bar_sid\",a.seriesIds.subarray(0,s),0,1),t.v.upload(\"bar_axis\",a.axes.subarray(0,s),0,1),t.v.upload(\"bar_color\",a.colors.subarray(0,s*3),0,3),(!e.Ye||e.Ye.length<s*3)&&(e.Ye=new Float32Array(Math.max(s*3,e.Ye?.length??0))),e.Ye.set(a.colors.subarray(0,s*3))}function jm(e,t){let n=e.An;if(n===0)return;let o=e.Rn,i=e.s,r=e.me.seriesId,s=za(n);for(let l=0;l<n;l++){let u=i[r[o[l]]].color;s.colors[l*3]=u[0],s.colors[l*3+1]=u[1],s.colors[l*3+2]=u[2]}let a=e.Ye;if(a&&a.length>=n*3){let l=!0;for(let u=0;u<n*3;u++)if(a[u]!==s.colors[u]){l=!1;break}if(l)return}t.v.upload(\"bar_color\",s.colors.subarray(0,n*3),0,3),(!a||a.length<n*3)&&(e.Ye=new Float32Array(n*3)),e.Ye.set(s.colors.subarray(0,n*3))}function Xa(e){e.N.lines.invalidateBuffers(e),e.N.scatter.invalidateBuffers(e),e.N.areas.invalidateBuffers(e)}function ni(e,t){e.N.lines.rebuildBuffers(e,t),e.N.scatter.rebuildBuffers(e,t),e.N.areas.rebuildBuffers(e,t)}function $a(e,t){let n=t.gl,o=t.dpr,i=n.canvas.width/o,r=n.canvas.height/o;if(i<=0||r<=0||e.ee===0)return;let s=e.A();Lr(e)&&e.An>0&&jm(e,t);let a=e.Ze,l=e.Ke===\"numeric\",u=l?e.D.min:-.5,m=l?e.D.max:e.ee-.5,f=e.oi.min,p=e.oi.max;e.g&&(a?e.g.setBaseDomain(f,p,u,m):e.g.setBaseDomain(u,m,f,p));let d=u,b=m,x=f,h=p,g=e.te?.min??0,y=e.te?.max??1;if(e.g){let V=e.g.getVisibleDomain();a?(x=V.xMin,h=V.xMax,d=V.yMin,b=V.yMax):(d=V.xMin,b=V.xMax,x=V.yMin,h=V.yMax)}let _=a?!e.g?.isYDefault():!e.g?.isXDefault();if(e.io&&e.g&&_){let V=nf(e,d,b);V.hasLeft&&(x=V.leftMin,h=V.leftMax),e.te&&V.hasRight&&(g=V.rightMin,y=V.rightMax)}if(e.h.include_zero&&(x>0&&(x=0),h<0&&(h=0),e.te&&(g>0&&(g=0),y<0&&(y=0))),e.on&&e.fe.length>1){qm(e,t,{horizontal:a,numericCat:l,cssWidth:i,cssHeight:r,visCatMin:d,visCatMax:b,visValMin:x,visValMax:h,visRightMin:g,visRightMax:y});return}e.m=null;let C=e.s.length>1,v=e._.length>0,A={levels:e.we,numRows:e.ee,levelLabels:e._.slice()},T=e.rn,L=e.wn===\"category\"&&T!==null&&T.numRows>0,R;if(a){let V=l?55:Mt(A),O=V+(v?16:0),X=C?80:16,q=Math.max(1,i-O-X),le=L?We(T,q):void 0;R=new ne(i,r,{hasXLabel:!0,hasYLabel:v,hasLegend:C,leftExtra:V,bottomExtra:le})}else if(l){let V=L?Mt(T):void 0;R=new ne(i,r,{hasXLabel:v,hasYLabel:!0,hasLegend:C,bottomExtra:24,leftExtra:V})}else{let V=L?Mt(T):55,O=V+16,X=C?80:16,q=Math.max(1,i-O-X),le=We(A,q);R=new ne(i,r,{hasXLabel:v,hasYLabel:!0,hasLegend:C,bottomExtra:le,leftExtra:L?V:void 0})}e.l=R,e.g&&e.g.updateLayout(R);let F=e.h.include_zero,I=a?R.buildProjectionMatrix(x,h,b,d,\"x\",F,void 0,0,e.se):R.buildProjectionMatrix(d,b,x,h,\"y\",F,void 0,e.se,0),S;if(e.tn&&e.te&&!a){let V=R.Y,O=R.J,X=R.q,q=R.Q;S=R.buildProjectionMatrix(d,b,g,y,\"y\",F,void 0,e.se,0),R.Y=V,R.J=O,R.q=X,R.Q=q}else S=I;let D=ie(x,h,6),B=e.tn&&e.te&&!a?ie(g,y,6):null,N=A,k={min:x,max:h,label:e.ii},Y=e.te&&!a?{min:g,max:y,label:e.Oi}:null;e.j&&si(e.j,R,D,s,t.dpr,a);let W=e.s.length>1?Ut(e):null;ze(n,R,t.dpr,()=>{ja(e,n,t,I,S,s.Qn,a,W?W.seriesId:-1)}),e.he=N,e.xe=k,e.Re=D,e._o=Y,e.vo=B,e.ze=l?ie(d,b,6):null,e.pe(()=>Za(e))}function ja(e,t,n,o,i,r,s,a,l){let u=e.Nt,m=u.length<=1;for(let f of u){let p=m?void 0:{start:f.aggStart,end:f.aggEnd};switch(f.chartType){case\"area\":s||e.N.areas.draw(e,t,n,o,i,r,l,p);break;case\"bar\":{t.useProgram(e.o);let d=e.F;t.uniformMatrix4fv(d.u_proj_left,!1,o),t.uniformMatrix4fv(d.u_proj_right,!1,i),t.uniform1f(d.u_horizontal,s?1:0),t.uniform1f(d.u_hover_series,a),ka(e,t,n,Zm(e,f,l));break}case\"line\":s||e.N.lines.draw(e,t,n,o,i,l,p);break;case\"scatter\":s||e.N.scatter.draw(e,t,n,o,i,l,p);break}}}function Zm(e,t,n){let o=n!==void 0?e.Ln?.[n]:e.Tn;if(!o)return n!==void 0?{start:0,count:0}:void 0;let i=o[t.aggStart],r=o[t.aggEnd];return{start:i.start,count:r.start+r.count-i.start}}function qm(e,t,n){let o=t.gl,i=t.dpr,r=e.A(),{horizontal:s,numericCat:a,cssWidth:l,cssHeight:u,visCatMin:m,visCatMax:f,visValMin:p,visValMax:d,visRightMin:b,visRightMax:x}=n,h=e._.length>0,g=e.rn,y=e.wn===\"category\"&&g!==null&&g.numRows>0,_=e.vt.length>1,C=a?\"outer\":\"cell\",v=y?\"cell\":\"outer\",A=Re(e.fe,{cssWidth:l,cssHeight:u,xAxis:s?v:C,yAxis:s?C:v,hasLegend:_,hasXLabel:s?!0:h,hasYLabel:s?h:!0,gap:e.G.facet_padding});if(e.m=A,e.l=A.cells[0]?.layout??null,A.cells.length===0||!e.l)return;e.syncFacetZoomLayouts(A.cells);let T=ie(p,d,6),L=a?ie(m,f,6):null,R=A.cells[0].layout,F=e.j;F&&e.pe(()=>ue(F,R,i));let I=e.h.include_zero,S=e.s.length>1?Ut(e):null,D=e.tn&&e.te!==null&&!s;at(o);for(let B=0;B<A.cells.length;B++){let k=A.cells[B].layout,Y=s?k.buildProjectionMatrix(p,d,f,m,\"x\",I,void 0,0,e.se):k.buildProjectionMatrix(m,f,p,d,\"y\",I,void 0,e.se,0),W=Y;if(D){let V=k.Y,O=k.J,X=k.q,q=k.Q;W=k.buildProjectionMatrix(m,f,b,x,\"y\",I,void 0,e.se,0),k.Y=V,k.J=O,k.q=X,k.Q=q}F&&e.pe(()=>Km(F,k,T,r,i,s)),lt(o,k,i,()=>{ja(e,o,t,Y,W,r.Qn,s,S&&S.splitIdx===B?S.seriesId:-1,B)})}e.he={levels:e.we,numRows:e.ee,levelLabels:e._.slice()},e.xe={min:p,max:d,label:e.ii},e.Re=T,e._o=null,e.vo=null,e.ze=L,e.pe(()=>Za(e))}function Km(e,t,n,o,i,r){let s=re(e,i);s&&(s.strokeStyle=o.un,s.lineWidth=1,r?Lt(s,t.e,n,a=>t.P(a,0).px):Tt(s,t.e,n,a=>t.P(0,a).py))}function Cr(e,t){return e.m?e.m.cells[t.splitIdx]?.layout??null:e.l}function Za(e){if(!e.c||!e.l||!e.xe||!e.Re)return;if(e.m){Jm(e);return}let t=e.A(),n;if(e.Ke===\"numeric\"&&e.D&&e.ze)n={mode:\"numeric\",domain:{min:e.D.min,max:e.D.max,isDate:e.D.isDate,label:e.D.label},ticks:e.ze};else if(e.he)n={mode:\"category\",domain:e.he};else return;let o=e.s.find(l=>l.axis===0),i=e.s.find(l=>l.axis===1),r=e._[0],s=e.wn===\"category\"&&e.rn?{mode:\"category\",domain:e.rn}:{mode:\"numeric\",domain:e.xe,ticks:e.Re},a;e._o&&e.vo&&(a=e.Vi===\"category\"&&e.ri?{mode:\"category\",domain:e.ri}:{mode:\"numeric\",domain:e._o,ticks:e.vo}),ri(e.c,n,s,e.l,t,e.t?.dpr??1,a,e.Ze,{value:e.getColumnFormatter(o?.aggName??null,\"tick\"),alt:e.getColumnFormatter(i?.aggName??null,\"tick\"),category:e.getColumnFormatter(r,\"tick\")}),tf(e),Ut(e)&&qa(e)}function Jm(e){let t=e.m,n=e.c,o=e.A(),i=e.t?.dpr??1,r=e.Ze,s=e._.length>0,a=e.Ke===\"numeric\"&&e.D!==null&&e.ze!==null;if(!ue(n,e.l,i))return;let l=e.he,u=e.xe,m=e.Re,f=e.rn,p=e.wn===\"category\"&&f!==null&&f.numRows>0,d=e.s.find(g=>g.axis===0),b=e.getColumnFormatter(d?.aggName??null,\"tick\"),x=e.getColumnFormatter(e._[0],\"tick\");for(let g of t.cells){let y=g.layout,_=y.e,C=re(n,i);C&&(C.strokeStyle=o.Jn,C.lineWidth=1,C.beginPath(),C.moveTo(_.x,_.y),C.lineTo(_.x,_.y+_.height),C.lineTo(_.x+_.width,_.y+_.height),C.stroke(),r?(!a&&l&&we(C,y,l,o),p&&pe(C,y,f,o)):(!a&&l&&pe(C,y,l,o),p&&we(C,y,f,o)),g.titleRect&&_t(n,g.label,g.titleRect,o,i))}let h=a?{min:e.D.min,max:e.D.max,isDate:e.D.isDate,label:e.D.label}:null;r?(h&&t.outerYAxisRect&&an(n,t.outerYAxisRect,h,e.ze,tn(t),o,s,i,x),!p&&t.outerXAxisRect&&sn(n,t.outerXAxisRect,u,m,en(t),o,!0,i,b)):(h&&t.outerXAxisRect&&sn(n,t.outerXAxisRect,h,e.ze,en(t),o,s,i,x),!p&&t.outerYAxisRect&&an(n,t.outerYAxisRect,u,m,tn(t),o,!0,i,b)),Qm(e,t),Ut(e)&&qa(e)}function Qm(e,t){if(e.nn=[],!e.c||!t.legendRect)return;let n=e.vt.length;if(n<=1)return;let o=e.c.getContext(\"2d\");if(!o)return;o.save();let i=e.A(),r=10,s=18,a=t.legendRect.x+12,l=t.legendRect.y+10;o.font=`11px ${i.fontFamily}`,o.textAlign=\"left\",o.textBaseline=\"middle\";for(let u=0;u<n;u++){let m=[],f=[.5,.5,.5];for(let y of e.s)y.aggIdx===u&&(m.push(y.seriesId),f=y.color);let p=e.vt[u],d=m.every(y=>e.K.has(y)),b=Math.round(f[0]*255),x=Math.round(f[1]*255),h=Math.round(f[2]*255);o.globalAlpha=d?.3:1,o.fillStyle=`rgb(${b},${x},${h})`,o.fillRect(a,l-r/2,r,r),o.fillStyle=i.mn,o.fillText(p,a+r+6,l);let g=o.measureText(p).width;d&&(o.strokeStyle=i.mn,o.lineWidth=1,o.beginPath(),o.moveTo(a+r+6,l),o.lineTo(a+r+6+g,l),o.stroke()),o.globalAlpha=1,e.nn.push({seriesIds:m,rect:{x:a-2,y:l-s/2,width:r+6+g+4,height:s}}),l+=s}o.restore()}var ai=new Float64Array(0);function ef(e,t,n){if(e.xo)return;let o=e.s;ai.length<o.length&&(ai=new Float64Array(o.length)),t.save(),t.font=`11px ${n}`;for(let i=0;i<o.length;i++)ai[i]=t.measureText(o[i].label).width;t.restore(),e.xo=!0}function tf(e){if(e.nn=[],!e.c||!e.l||e.s.length<=1)return;let t=e.c.getContext(\"2d\");if(!t)return;t.save();let n=e.A(),o=n.mn,i=n.fontFamily;ef(e,t,i);let r=e.l,s=10,a=18,l=r.e.x+r.e.width+12,u=r.margins.top+10;t.font=`11px ${i}`,t.textAlign=\"left\",t.textBaseline=\"middle\";let m=e.s,f=ai;for(let p=0;p<m.length;p++){let d=m[p],b=e.K.has(d.seriesId),x=Math.round(d.color[0]*255),h=Math.round(d.color[1]*255),g=Math.round(d.color[2]*255);t.globalAlpha=b?.3:1,t.fillStyle=`rgb(${x},${h},${g})`,t.fillRect(l,u-s/2,s,s),t.fillStyle=o,t.fillText(d.label,l+s+6,u);let y=f[p];b&&(t.strokeStyle=o,t.lineWidth=1,t.beginPath(),t.moveTo(l+s+6,u),t.lineTo(l+s+6+y,u),t.stroke()),t.globalAlpha=1;let _={x:l-2,y:u-a/2,width:s+6+y+4,height:a};e.nn.push({seriesIds:[d.seriesId],rect:_}),u+=a}t.restore()}function qa(e){if(!e.c||!e.l)return;let t=Ut(e);if(!t)return;let n=Cr(e,t);if(!n)return;let i=(e.s[t.seriesId]?.chartType??\"bar\")===\"bar\"?(t.y0+t.y1)/2:t.y1,r=t.axis===0?e.Ze?n.P(i,t.xCenter):n.P(t.xCenter,i):_r(e,t.xCenter,i,n),s=yr(e,t),a=e.A();Pe(e.c,r,s,n,a,e.t?.dpr??1)}function _r(e,t,n,o){let i=o??e.l,{x:r,y:s,width:a,height:l}=i.e,u=(t-i.Y)/(i.J-i.Y),m=e.te,f=(n-m.min)/(m.max-m.min);return{px:r+u*a,py:s+(1-f)*l}}function nf(e,t,n){let o=e._t;if(o&&o.catMin===t&&o.catMax===n&&o.hidden===e.K)return o;let i=sf(e),r=1/0,s=-1/0,a=!1,l=1/0,u=-1/0,m=!1;if(i.n>0){let p=e.qe,d,b;if(p){let v=of(p,i.n,t,n);d=v.lo,b=v.hi}else d=Math.max(0,Math.floor(t)),b=Math.min(i.n-1,Math.ceil(n));let x=i.leftMin,h=i.leftMax,g=i.rightMin,y=i.rightMax,_=i.hasLeft,C=i.hasRight;for(let v=d;v<=b;v++)_[v]&&(x[v]<r&&(r=x[v]),h[v]>s&&(s=h[v]),a=!0),C[v]&&(g[v]<l&&(l=g[v]),y[v]>u&&(u=y[v]),m=!0)}let f=o??rf();return f.catMin=t,f.catMax=n,f.hidden=e.K,f.leftMin=r,f.leftMax=s,f.hasLeft=a,f.rightMin=l,f.rightMax=u,f.hasRight=m,e._t=f,f}function of(e,t,n,o){if(t===0||n>o)return{lo:0,hi:-1};let i=0,r=t;for(;i<r;){let l=i+r>>>1;e[l]<n?i=l+1:r=l}let s=Math.max(0,i-1);for(i=0,r=t;i<r;){let l=i+r>>>1;e[l]<=o?i=l+1:r=l}let a=Math.min(t-1,i);return{lo:s,hi:a}}function rf(){return{catMin:0,catMax:0,hidden:new Set,leftMin:0,leftMax:0,hasLeft:!1,rightMin:0,rightMax:0,hasRight:!1}}function sf(e){let t=e.ee,n=e.Hi,o=n&&n.leftMin.length>=t;if(n&&o&&e.yo===e.K)return n;!n||!o?(n={leftMin:new Float64Array(t),leftMax:new Float64Array(t),rightMin:new Float64Array(t),rightMax:new Float64Array(t),hasLeft:new Uint8Array(t),hasRight:new Uint8Array(t),n:t},e.Hi=n):n.n=t;for(let x=0;x<t;x++)n.leftMin[x]=1/0,n.leftMax[x]=-1/0,n.rightMin[x]=1/0,n.rightMax[x]=-1/0,n.hasLeft[x]=0,n.hasRight[x]=0;let i=e.me,r=e.K,s=i.catIdx,a=i.seriesId,l=i.y0,u=i.y1,m=i.axis;for(let x=0;x<i.count;x++){if(r.has(a[x]))continue;let h=s[x];if(h<0||h>=t)continue;let g=l[x],y=u[x],_=g<y?g:y,C=g<y?y:g;m[x]===1?(_<n.rightMin[h]&&(n.rightMin[h]=_),C>n.rightMax[h]&&(n.rightMax[h]=C),n.hasRight[h]=1):(_<n.leftMin[h]&&(n.leftMin[h]=_),C>n.leftMax[h]&&(n.leftMax[h]=C),n.hasLeft[h]=1)}let f=[e.Mn,e.Fn],p=e.je,d=e.Ut,b=e.s.length;for(let x of f)for(let h of x){if(r.has(h.seriesId))continue;let g=h.axis===1,y=h.seriesId;for(let _=0;_<t;_++){let C=_*b+y;if(!(d[C>>3]>>(C&7)&1))continue;let v=p[C];g?(v<n.rightMin[_]&&(n.rightMin[_]=v),v>n.rightMax[_]&&(n.rightMax[_]=v),n.hasRight[_]=1):(v<n.leftMin[_]&&(n.leftMin[_]=v),v>n.leftMax[_]&&(n.leftMax[_]=v),n.hasLeft[_]=1)}}return e.yo=r,n}nn();Me();fe();var _n=new Float32Array(0),vn=new Uint8Array(0);function af(e){return _n.length>=e||(_n=new Float32Array(Math.max(e,_n.length*2))),_n}function lf(e){return vn.length>=e||(vn=new Uint8Array(Math.max(e,vn.length*2))),vn}function uf(e){return e===\"solid\"?1:e===\"transparent\"?.5:0}var li=class{constructor(){c(this,\"o\",null);c(this,\"i\",null)}ensureProgram(t){if(this.o)return this.o;let n=je(t.gl),o=j(t,\"bar-line\",Oe,Ve,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_start\",\"a_end\",\"a_corner\",\"a_real_start\",\"a_real_end\"]);return this.o={...o,cornerBuffer:n},this.o}invalidateBuffers(t){let n=this.i;if(!n||!t.t){this.i=null;return}let o=t.t.gl;for(let i of n.series)o.deleteBuffer(i.gpuBuffer),o.deleteBuffer(i.gpuRealBuffer);this.i=null}rebuildBuffers(t,n){let o=t.Mn;if(o.length===0){this.i=null;return}if(t.ee===0){this.i=null;return}this.ensureProgram(n);let r=n.gl,s=t.je,a=t.Ut,l=t.se,u=t.qe,m=t.s.length,f=[];for(let p of o){let d=t.s[p.seriesId],b=d.start,x=d.end;if(b<0||x<b)continue;let h=x-b+1;if(h<2)continue;let g=af(h*2),y=lf(h),_=0;for(let A=b;A<=x;A++){let T=u?u[A]-l:A,L=A*m+p.seriesId;g[_*2]=T,g[_*2+1]=s[L],y[_]=a[L>>3]>>(L&7)&1,_++}let C=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,C),r.bufferData(r.ARRAY_BUFFER,g.subarray(0,_*2),r.STATIC_DRAW);let v=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,v),r.bufferData(r.ARRAY_BUFFER,y.subarray(0,_),r.STATIC_DRAW),f.push({seriesId:p.seriesId,axis:p.axis,color:[p.color[0],p.color[1],p.color[2]],gpuBuffer:C,gpuRealBuffer:v,count:h,interpolateMode:d.interpolateMode})}this.i={series:f}}draw(t,n,o,i,r,s,a){let l=this.i,u=this.o;if(!l||!u||l.series.length===0)return;let m=o.dpr;n.useProgram(u.program),n.uniform2f(u.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(u.u_line_width,t.h.line_width_px*m);let f=J(o),{setDivisor:p,drawArraysInstanced:d}=f;n.bindBuffer(n.ARRAY_BUFFER,u.cornerBuffer),n.enableVertexAttribArray(u.a_corner),n.vertexAttribPointer(u.a_corner,1,n.FLOAT,!1,0,0),p(u.a_corner,0);let b=2*Float32Array.BYTES_PER_ELEMENT,x=Uint8Array.BYTES_PER_ELEMENT,h=t.K;for(let g of l.series){if(h.has(g.seriesId)||s!==void 0&&t.s[g.seriesId].splitIdx!==s)continue;let y=t.s[g.seriesId].aggIdx;if(a!==void 0&&(y<a.start||y>a.end))continue;n.uniformMatrix4fv(u.u_projection,!1,g.axis===1?r:i);let _=t.s[g.seriesId].color;n.uniform4f(u.u_color,_[0],_[1],_[2],1),n.uniform1f(u.u_interp_alpha,uf(g.interpolateMode)),n.enableVertexAttribArray(u.a_start),p(u.a_start,1),n.enableVertexAttribArray(u.a_end),p(u.a_end,1),n.enableVertexAttribArray(u.a_real_start),p(u.a_real_start,1),n.enableVertexAttribArray(u.a_real_end),p(u.a_real_end,1),n.bindBuffer(n.ARRAY_BUFFER,g.gpuBuffer),n.vertexAttribPointer(u.a_start,2,n.FLOAT,!1,b,0),n.vertexAttribPointer(u.a_end,2,n.FLOAT,!1,b,b),n.bindBuffer(n.ARRAY_BUFFER,g.gpuRealBuffer),n.vertexAttribPointer(u.a_real_start,1,n.UNSIGNED_BYTE,!1,x,0),n.vertexAttribPointer(u.a_real_end,1,n.UNSIGNED_BYTE,!1,x,x),d(n.TRIANGLE_STRIP,0,4,g.count-1)}p(u.a_start,0),p(u.a_end,0),p(u.a_real_start,0),p(u.a_real_end,0)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let o=this.o;o&&n.deleteBuffer(o.cornerBuffer)}this.o=null,this.i=null}};fe();var Ne=new Float32Array(0),Ce=new Float32Array(0);function mf(e){Ne.length<e*2&&(Ne=new Float32Array(Math.max(e*2,Ne.length*2))),Ce.length<e*3&&(Ce=new Float32Array(Math.max(e*3,Ce.length*2)))}var ui=class{constructor(){c(this,\"o\",null);c(this,\"i\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,o=j(t,\"bar-scatter\",Wn,kn,[\"u_projection\",\"u_point_size\"],[\"a_position\",\"a_color\"]);return this.o={...o,posLeftBuffer:n.createBuffer(),posRightBuffer:n.createBuffer(),colorLeftBuffer:n.createBuffer(),colorRightBuffer:n.createBuffer()},this.o}invalidateBuffers(t){this.i=null}rebuildBuffers(t,n){let o=t.Fn;if(o.length===0){this.i=null;return}let i=t.ee,r=t.s.length;if(i===0||r===0){this.i=null;return}let s=this.ensureProgram(n),a=n.gl,l=t.je,u=t.Ut,m=t.qe,f=t.se,p=t.K,d=0,b=0;for(let _ of o)if(!p.has(_.seriesId))for(let C=0;C<i;C++){let v=C*r+_.seriesId;u[v>>3]>>(v&7)&1&&(_.axis===1?b++:d++)}let x=d+b;if(x===0){this.i=null;return}mf(x);let h=[],g=0,y=d;for(let _ of o){if(p.has(_.seriesId))continue;let C=_.axis===1?y-d:g,v=_.color[0],A=_.color[1],T=_.color[2];for(let R=0;R<i;R++){let F=R*r+_.seriesId;if(!(u[F>>3]>>(F&7)&1))continue;let I=m?m[R]-f:R,S=l[F];_.axis===1?(Ne[y*2]=I,Ne[y*2+1]=S,Ce[y*3]=v,Ce[y*3+1]=A,Ce[y*3+2]=T,y++):(Ne[g*2]=I,Ne[g*2+1]=S,Ce[g*3]=v,Ce[g*3+1]=A,Ce[g*3+2]=T,g++)}let L=_.axis===1?y-d:g;L>C&&h.push({seriesId:_.seriesId,axis:_.axis,first:C,count:L-C})}d>0&&(a.bindBuffer(a.ARRAY_BUFFER,s.posLeftBuffer),a.bufferData(a.ARRAY_BUFFER,Ne.subarray(0,d*2),a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,s.colorLeftBuffer),a.bufferData(a.ARRAY_BUFFER,Ce.subarray(0,d*3),a.STATIC_DRAW)),b>0&&(a.bindBuffer(a.ARRAY_BUFFER,s.posRightBuffer),a.bufferData(a.ARRAY_BUFFER,Ne.subarray(d*2,x*2),a.STATIC_DRAW),a.bindBuffer(a.ARRAY_BUFFER,s.colorRightBuffer),a.bufferData(a.ARRAY_BUFFER,Ce.subarray(d*3,x*3),a.STATIC_DRAW)),this.i={leftCount:d,rightCount:b,seriesRanges:h}}draw(t,n,o,i,r,s,a){let l=this.i,u=this.o;if(!l||!u||l.leftCount===0&&l.rightCount===0)return;let m=o.dpr;if(n.useProgram(u.program),n.uniform1f(u.u_point_size,t.h.point_size_px*m),s!==void 0||a!==void 0){for(let f of l.seriesRanges){if(s!==void 0&&t.s[f.seriesId].splitIdx!==s)continue;let p=t.s[f.seriesId].aggIdx;a!==void 0&&(p<a.start||p>a.end)||Tr(n,u,f.axis===1?u.posRightBuffer:u.posLeftBuffer,f.axis===1?u.colorRightBuffer:u.colorLeftBuffer,f.count,f.axis===1?r:i,f.first)}return}Tr(n,u,u.posLeftBuffer,u.colorLeftBuffer,l.leftCount,i),Tr(n,u,u.posRightBuffer,u.colorRightBuffer,l.rightCount,r)}destroy(t){let n=t.t?.gl;if(n){let o=this.o;o&&(n.deleteBuffer(o.posLeftBuffer),n.deleteBuffer(o.posRightBuffer),n.deleteBuffer(o.colorLeftBuffer),n.deleteBuffer(o.colorRightBuffer))}this.o=null,this.i=null}};function Tr(e,t,n,o,i,r,s=0){i!==0&&(e.uniformMatrix4fv(t.u_projection,!1,r),e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(t.a_position),e.vertexAttribPointer(t.a_position,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(t.a_color),e.vertexAttribPointer(t.a_color,3,e.FLOAT,!1,0,0),e.drawArrays(e.POINTS,s,i))}fe();var An=new Float32Array(0);function ff(e){return An.length>=e||(An=new Float32Array(Math.max(e,An.length*2))),An}var mi=class{constructor(){c(this,\"o\",null);c(this,\"i\",null)}ensureProgram(t){return this.o?this.o:(this.o=j(t,\"bar-area\",En,Gn,[\"u_projection\",\"u_color\",\"u_opacity\"],[\"a_position\"]),this.o)}invalidateBuffers(t){let n=this.i;if(!n||!t.t){this.i=null;return}let o=t.t.gl;for(let i of n.series)o.deleteBuffer(i.gpuBuffer);this.i=null}rebuildBuffers(t,n){let o=t.Ao;if(o.length===0){this.i=null;return}let i=t.ee,r=t.s.length;if(i===0||r===0){this.i=null;return}this.ensureProgram(n);let s=n.gl,a=t.je,l=t.Ut,u=t.qe,m=t.se,f=t.si,p=t.me,d=[];for(let b of o){let x=t.s[b.seriesId],h=cf(b,i,r,a,l,f,p.y0,p.y1,u,m,x.start,x.end,x.interpolateMode);if(h.totalVertices===0)continue;let g=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,g),s.bufferData(s.ARRAY_BUFFER,h.scratch.subarray(0,h.totalVertices*2),s.STATIC_DRAW),d.push({seriesId:b.seriesId,axis:b.axis,color:[b.color[0],b.color[1],b.color[2]],gpuBuffer:g,strips:h.descriptors})}this.i={series:d}}draw(t,n,o,i,r,s,a,l){let u=this.i,m=this.o;if(!u||!m||u.series.length===0)return;n.useProgram(m.program),n.uniform1f(m.u_opacity,s);let f=t.K;for(let p of u.series){if(f.has(p.seriesId)||a!==void 0&&t.s[p.seriesId].splitIdx!==a)continue;let d=t.s[p.seriesId].aggIdx;if(l!==void 0&&(d<l.start||d>l.end))continue;n.uniformMatrix4fv(m.u_projection,!1,p.axis===1?r:i);let b=t.s[p.seriesId].color;n.uniform3f(m.u_color,b[0],b[1],b[2]),n.bindBuffer(n.ARRAY_BUFFER,p.gpuBuffer),n.enableVertexAttribArray(m.a_position),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,0);for(let x of p.strips)n.bindBuffer(n.ARRAY_BUFFER,p.gpuBuffer),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,x.offsetBytes),n.drawArrays(n.TRIANGLE_STRIP,0,x.vertexCount)}}destroy(t){this.invalidateBuffers(t),this.o=null}};function cf(e,t,n,o,i,r,s,a,l,u,m,f,p){let d=ff(t*4),b=[],x=e.seriesId*1e9,h=p!==\"skip\",g=0,y=0;for(let _=0;_<t;_++){let C=0,v=0,A=!1;if(e.stack){let T=r?.get(x+_);T!==void 0&&(C=s[T],v=a[T],A=!0)}else{let T=_*n+e.seriesId;h?_>=m&&_<=f&&(v=o[T],A=!0):i[T>>3]>>(T&7)&1&&(v=o[T],A=!0)}if(A){let T=l?l[_]-u:_;d[g++]=T,d[g++]=C,d[g++]=T,d[g++]=v}else if(g>y){let T=(g-y)/2;T>=4&&b.push({offsetBytes:y*4,vertexCount:T}),y=g}}if(g>y){let _=(g-y)/2;_>=4&&b.push({offsetBytes:y*4,vertexCount:_})}return{descriptors:b,totalVertices:g/2,scratch:d}}Me();fe();function Ln(e,t){return e&&(t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max)),{min:t.min,max:t.max}}var Je=class extends Nt{constructor(n=\"vertical\"){super();c(this,\"Ze\");c(this,\"F\",null);c(this,\"vt\",[]);c(this,\"fe\",[]);c(this,\"s\",[]);c(this,\"on\",!1);c(this,\"m\",null);c(this,\"Co\",null);c(this,\"Nt\",[]);c(this,\"Tn\",null);c(this,\"Ln\",null);c(this,\"me\",Qo());c(this,\"ai\",[]);c(this,\"Mn\",[]);c(this,\"Fn\",[]);c(this,\"Ao\",[]);c(this,\"ii\",\"\");c(this,\"Oi\",\"\");c(this,\"wn\",\"numeric\");c(this,\"Vi\",null);c(this,\"rn\",null);c(this,\"ri\",null);c(this,\"si\",null);c(this,\"Ye\",null);c(this,\"Lo\",null);c(this,\"To\",null);c(this,\"li\",null);c(this,\"ui\",null);c(this,\"oi\",{min:0,max:1});c(this,\"te\",null);c(this,\"tn\",!1);c(this,\"Sn\",null);c(this,\"In\",null);c(this,\"Ro\",null);c(this,\"Ke\",\"category\");c(this,\"D\",null);c(this,\"se\",0);c(this,\"ze\",null);c(this,\"qe\",null);c(this,\"K\",new Set);c(this,\"Me\",-1);c(this,\"ni\",-1);c(this,\"Fe\",null);c(this,\"je\",new Float32Array(0));c(this,\"Ut\",new Uint8Array(0));c(this,\"N\",{lines:new li,scatter:new ui,areas:new mi});c(this,\"_o\",null);c(this,\"vo\",null);c(this,\"An\",0);c(this,\"Rn\",new Int32Array(0));c(this,\"nn\",[]);c(this,\"xo\",!1);c(this,\"_t\",null);c(this,\"Hi\",null);c(this,\"yo\",null);this.Ze=n===\"horizontal\"}getZoomConfig(){return{lockAxis:this.Ze?\"x\":\"y\"}}tooltipCallbacks(){return{onHover:(n,o)=>xr(this,n,o),onLeave:()=>{(this.Me!==-1||this.Fe)&&(this.Me=-1,this.Fe=null,this.t&&this.requestRender(this.t))},onClickPre:(n,o)=>Ua(this,n,o),onPin:(n,o)=>{if(xr(this,n,o),this.Me>=0){let i=this.Me;Oa(this,i);let r=Cn(this.me,i,this.fe.length,this.je,this.s.length);this.Yi(r)}else if(this.Fe){let i=this.Fe;Va(this,i),this.Yi(i)}},onUnpin:()=>{this.emitUnselect()}}}async Yi(n){if(!this.vt[n.aggIdx])return;let o=this.we.map(s=>s.labels[n.catIdx]??null),i=this.fe[n.splitIdx]??\"\",r=this.B.length>0&&i!==\"\"?i.split(\"|\"):[];await this.emitClickAndSelect({rowIdx:n.catIdx+this.mt,columnName:this.vt[n.aggIdx],groupByValues:o,splitByValues:r})}async uploadAndRender(n,o,i,r){this.t=n;let s=n.gl;if(i!==0)return;if(!this.o){let u=j(n,\"bar\",Fn,Sn,[\"u_proj_left\",\"u_proj_right\",\"u_hover_series\",\"u_horizontal\"],[\"a_corner\",\"a_x_center\",\"a_half_width\",\"a_y0\",\"a_y1\",\"a_color\",\"a_series_id\",\"a_axis\"]);this.o=u.program,this.F=u,this.k=Lo(s)}let a=this.B.length>0&&this.G.facet_mode===\"grid\",l=Wa({columns:o,numRows:r,columnSlots:this.I,groupBy:this._,splitBy:this.B,groupByTypes:this.ht,columnsConfig:this.Oo,defaultChartType:this.no,autoAltYAxis:this.h.auto_alt_y_axis,bandInnerFrac:this.h.band_inner_frac,barInnerPad:this.h.bar_inner_pad,includeZero:this.h.include_zero,facetSplits:a,scratchBars:this.me,scratchPosStack:this.li,scratchNegStack:this.ui});if(this.h.domain_mode===\"expand\"){let u=pf(l);this.Ro!==u&&(this.Sn=null,this.In=null,this.Ro=u),this.Sn=Ln(this.Sn,l.leftDomain),l.rightDomain&&(this.In=Ln(this.In,l.rightDomain))}else this.Sn=null,this.In=null,this.Ro=null;this.vt=l.aggregates,this.fe=l.splitPrefixes,this.on=a&&l.splitPrefixes.length>1,this.we=l.rowPaths,this.ee=l.numCategories,this.mt=l.rowOffset,this.Ke=l.axisMode.mode,this.D=l.numericCategoryDomain,this.qe=l.categoryPositions,this.se=l.numericCategoryDomain?.min??0,this.s=l.series,this.me=l.bars,this.li=l.posStack,this.ui=l.negStack,this.je=l.samples,this.ai.length=0,this.Mn.length=0,this.Fn.length=0,this.Ao.length=0;for(let u of l.series)switch(u.chartType){case\"bar\":this.ai.push(u);break;case\"line\":this.Mn.push(u);break;case\"scatter\":this.Fn.push(u);break;case\"area\":this.Ao.push(u);break}this.ii=Ka(l.series,0),this.Oi=Ka(l.series,1),this.Nt.length=0;{let u=Math.max(1,l.splitPrefixes.length);for(let m=0;m<l.aggregates.length;m++){let f=l.series[m*u].chartType,p=this.Nt[this.Nt.length-1];p&&p.chartType===f?p.aggEnd=m:this.Nt.push({chartType:f,aggStart:m,aggEnd:m})}}this.si=df(this.me),this._t=null,this.xo=!1,this.Lo=null,this.To=null,this.yo=null,this.Ye=null,this.Me=-1,this.Fe=null,this.Ut=l.sampleValid,this.oi=l.leftDomain,this.te=l.rightDomain,this.tn=l.hasRightAxis,this.wn=l.leftValueAxisMode,this.Vi=l.rightValueAxisMode,this.rn=l.leftValueCategoryDomain,this.ri=l.rightValueCategoryDomain,Lr(this),ti(this,n),Xa(this),ni(this,n),await this.requestRender(n)}Dt(n){this.o&&(this.t=n,$a(this,n))}resetExpandedDomain(){this.Sn=null,this.In=null,this.Ro=null}destroyInternal(){if(this.t){let n=this.t.gl;this.k&&n.deleteBuffer(this.k),gf(this)}this.o=null,this.F=null,this.k=null,this.on=!1,this.m=null,this.Co=null,this.Ln=null,this.Tn=null,this.Nt.length=0,this.me=Qo(),this.s=[],this.ai=[],this.Mn=[],this.Fn=[],this.Ao=[],this.si=null,this.Lo=null,this.To=null,this.Ye=null,this.li=null,this.ui=null,this.we=[],this.ee=0,this.K.clear(),this.Me=-1,this.Fe=null}};function df(e){let t=new Map;for(let n=0;n<e.count;n++)e.chartType[n]===1&&t.set(e.seriesId[n]*1e9+e.catIdx[n],n);return t}function Ka(e,t){let n=new Set,o=[];for(let i of e)i.axis===t&&(n.has(i.aggName)||(n.add(i.aggName),o.push(i.aggName)));return o.join(\", \")}function pf(e){let t=Math.max(1,e.splitPrefixes.length),n=[];for(let o=0;o<e.aggregates.length;o++)n.push(`${e.aggregates[o]}:${e.series[o*t].axis}`);return n.join(\"\\0\")}function Lr(e){let t=e.A(),n=t.ke,o=t.H,i=e.on?Math.max(1,e.vt.length):e.s.length,r=e.To;if(e.Lo&&r&&r.ke===n&&r.H===o&&r.seriesLength===i)return!1;let s=bf(n,o,i);e.Lo=s,e.To={ke:n,H:o,seriesLength:i};for(let a=0;a<e.s.length;a++)e.s[a].color=e.on?s[e.s[a].aggIdx]:s[a];return!0}function bf(e,t,n){return de(e,t,n)}function gf(e){e.N.lines.destroy(e),e.N.scatter.destroy(e),e.N.areas.destroy(e)}var fi=class extends Je{constructor(){super(\"horizontal\")}};Jt();Ye();un();function Rr(e){let{columns:t,numRows:n,groupBy:o,splitBy:i,groupByTypes:r}=e,s=Gt(o,r),a={xLevels:[],yColumnNames:[],yLevels:[],numX:0,numY:0,rowOffset:0,cells:[],cells2D:[],colorMin:0,colorMax:1,xAxisMode:s,yAxisMode:{mode:\"category\"},xPositions:null,yPositions:null,xNumericDomain:null,yNumericDomain:null},l=o.map(R=>r[R]??\"string\"),{rowPaths:u,numCategories:m,rowOffset:f}=Wt(t,n,o.length,l),p=null,d=null;if(s.mode===\"numeric\"&&m>0){let R=t.get(\"__ROW_PATH_0__\"),F=ct(R?.values,m,f,o[0]??\"\",s.numericType===\"date\"||s.numericType===\"datetime\");F&&(p=F.categoryPositions,d=F.numericCategoryDomain)}let b=[];for(let R of t.keys())R.startsWith(\"__\")||!t.get(R)?.values||b.push(R);let x=b.length;if(m===0||x===0)return{...a,xLevels:u,rowOffset:f};let h=yf(b),g=hf(i,r),y={mode:\"category\"},_=null,C=null;if(g.mode===\"numeric\"){let R=xf(b,g.numericType);if(R){let F=ct(R,x,0,i[0]??\"\",g.numericType===\"date\"||g.numericType===\"datetime\");F&&(y=g,_=F.categoryPositions,C=F.numericCategoryDomain)}}let v=[],A=new Array(m*x).fill(null),T=1/0,L=-1/0;for(let R=0;R<x;R++){let F=t.get(b[R]),I=F.values,S=F.valid;for(let D=0;D<m;D++){let B=D+f;if(S&&!(S[B>>3]>>(B&7)&1))continue;let N=I[B];if(!isFinite(N))continue;let k={xIdx:D,yIdx:R,value:N};v.push(k),A[R*m+D]=k,N<T&&(T=N),N>L&&(L=N)}}return!isFinite(T)||!isFinite(L)?(T=0,L=1):T===L&&(L=T+1),{xLevels:u,yColumnNames:b,yLevels:h,numX:m,numY:x,rowOffset:f,cells:v,cells2D:A,colorMin:T,colorMax:L,xAxisMode:s,yAxisMode:y,xPositions:p,yPositions:_,xNumericDomain:d,yNumericDomain:C}}function hf(e,t){if(e.length!==1)return{mode:\"category\"};let n=t[e[0]];return n===\"date\"||n===\"datetime\"||n===\"integer\"||n===\"float\"?{mode:\"numeric\",numericType:n}:{mode:\"category\"}}function xf(e,t){let n=new Float64Array(e.length);for(let o=0;o<e.length;o++){let i=e[o],r=i.indexOf(\"|\"),s=r===-1?i:i.slice(0,r),a;if(t===\"date\"||t===\"datetime\"?(a=Date.parse(s),isFinite(a)||(a=Date.parse(s.replace(\" \",\"T\")))):a=Number(s),!isFinite(a))return null;n[o]=a}return n}function Ja(e,t){return t.map(n=>{let o=new Map;for(let[i,r]of e){if(i.startsWith(\"__ROW_PATH_\")||i===\"__GROUPING_ID__\"){o.set(i,r);continue}let s=i.lastIndexOf(\"|\");(s===-1?i:i.slice(s+1))===n&&o.set(i,r)}return{label:n,columns:o}})}function yf(e){if(e.length===0)return[];let t=0,n=e.map(i=>i.split(\"|\"));for(let i of n)i.length>t&&(t=i.length);if(t===0)return[];let o=[];for(let i=0;i<t;i++){let r=[],s=new Map,a=new Int32Array(e.length),l=new Array(e.length),u=0;for(let p=0;p<e.length;p++){let d=n[p][i]??\"\",b=s.get(d);b===void 0&&(b=r.length,r.push(d),s.set(d,b)),a[p]=b,l[p]=d,d.length>u&&(u=d.length)}let f=i===t-1?[]:go(a,r,0,e.length);o.push({labels:l,runs:f,maxLabelChars:u})}return o}Ye();mo();on();Me();fe();ut();vt();Ft();un();bo();function Mr(e,t){return t?.skipLeafLevel&&e.length>0?e.slice(0,-1):e}var Cf=80,_f=20,wr=5,Fr=11;function Ot(e,t){return e.P(0,t).py}function Qa(e,t){let n=Mr(e.levels,t),o=n.length,i=[];for(let r=0;r<o;r++){let s=n[r].maxLabelChars;if(r===o-1){let a=Math.max(Cf,s*6.5+16);i.push({size:a})}else{let a=Math.max(_f,s*6.5+16);i.push({size:a})}}return i}function el(e,t){let n=Mr(e.levels,t);if(e.numRows===0||n.length===0)return 55;let o=Qa(e,t),i=0;for(let r of o)i+=r.size;return i}function vf(e,t){return e.labels[t]??\"\"}function Sr(e,t,n,o,i){let r=Mr(n.levels,i);if(n.numRows===0||r.length===0)return;let{It:s,Le:a,fontFamily:l}=o,{e:u}=t;e.strokeStyle=s,e.fillStyle=s,e.lineWidth=1,e.font=`${Fr}px ${l}`;let m=Qa(n,i),f=Math.max(0,Math.ceil(t.q)),p=Math.min(n.numRows-1,Math.floor(t.Q));if(p<f)return;let d=r.length,b=u.x;for(let h=d-1;h>=0;h--){let g=r[h],y=m[h],_=b,C=b-y.size;b=C,h===d-1?Af(e,t,g,f,p,_,C,l,s):Lf(e,t,g,f,p,C,_,l,s)}let x=n.levelLabels.filter(h=>!!h).join(\" / \");x&&(e.fillStyle=a,e.font=`13px ${l}`,e.save(),e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"top\",e.fillText(x,0,0),e.restore())}function Af(e,t,n,o,i,r,s,a,l){let u=t.e;e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let f=o;f<=i;f++){let p=Ot(t,f);p<u.y-1||p>u.y+u.height+1||(e.moveTo(r,p),e.lineTo(r-wr,p))}e.stroke(),e.font=`${Fr}px ${a}`,e.textAlign=\"right\",e.textBaseline=\"middle\";let m=r-wr-4-s-4;for(let f=o;f<=i;f++){let p=Ot(t,f);if(p<u.y-1||p>u.y+u.height+1)continue;let d=vf(n,f);if(!d)continue;let b=mt(e,d,m);b&&e.fillText(b,r-wr-4,p)}}function Lf(e,t,n,o,i,r,s,a,l){let u=t.e,m=ln(n.runs,o,i);if(m.length===0)return;e.strokeStyle=l,e.fillStyle=l;let f=s-3;e.beginPath();for(let p of m){let d=Ot(t,p.endIdx+.5),b=Ot(t,p.startIdx-.5),x=Math.min(d,b),h=Math.max(d,b),g=Math.max(u.y,x),y=Math.min(u.y+u.height,h);y<=g||(e.moveTo(f,g),e.lineTo(f,y),e.moveTo(f,g),e.lineTo(f+3,g),e.moveTo(f,y),e.lineTo(f+3,y))}e.stroke(),e.font=`${Fr}px ${a}`;for(let p of m){let d=Ot(t,p.endIdx+.5),b=Ot(t,p.startIdx-.5),x=Math.min(d,b),h=Math.max(d,b),g=Math.max(u.y,x),y=Math.min(u.y+u.height,h);if(y<=g)continue;let _=(g+y)/2,C=r+(s-r-3)/2,v=p.label;if(!v)continue;let A=y-g-4,T=mt(e,v,Math.max(0,A));T&&(e.save(),e.translate(C,_),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"middle\",e.fillText(T,0,0),e.restore())}}Ae();yo();Ee();At();Ct();function Dr(e,t,n){if(e.zi=t,e.Xi=n,e.u.length>0){for(let i=0;i<e.u.length;i++){let r=e.u[i],s=r.layout.e;if(t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height)continue;let a=nl(r.layout,r.pipeline.numX,r.pipeline.numY,r.pipeline.cells2D,r.pipeline.xPositions,r.pipeline.yPositions,r.pipeline.xNumericDomain?.bandWidth??1,r.pipeline.yNumericDomain?.bandWidth??1,t,n);Ir(e,a,i);return}Ir(e,null,-1);return}if(!e.l)return;let o=nl(e.l,e.At,e.Lt,e.wo,e.Dn,e.Bn,e.ft?.bandWidth??1,e.ct?.bandWidth??1,t,n);Ir(e,o,-1)}function tl(e,t,n){if(e.length===0)return-1;let o=0,i=e.length-1;for(;o<i;){let s=o+i>>1;e[s]<t?o=s+1:i=s}let r=o;return r>0&&Math.abs(e[r-1]-t)<Math.abs(e[r]-t)&&(r-=1),Math.abs(e[r]-t)>n*.5?-1:r}function nl(e,t,n,o,i,r,s,a,l,u){let m=e.e;if(l<m.x||l>m.x+m.width||u<m.y||u>m.y+m.height)return null;let f=e.Y,p=e.J,d=e.q,b=e.Q,x=f+(l-m.x)/m.width*(p-f),h=b-(u-m.y)/m.height*(b-d),g=i?tl(i,x,s):Math.round(x),y=r?tl(r,h,a):Math.round(h);return g<0||g>=t||y<0||y>=n?null:o[y*t+g]??null}function Ir(e,t,n){let o=e.Ge;(o?.xIdx??-1)===(t?.xIdx??-1)&&(o?.yIdx??-1)===(t?.yIdx??-1)&&e.Pn===n||(e.Ge=t,e.Pn=n,e.t&&e.mi&&e.mi())}function ol(e,t){let n=[];for(let o of e){let i=o.labels[t];i!=null&&i!==\"\"&&n.push(i)}return n.join(\" / \")}function Br(e){if(!e.c||!e.Ge)return;let t,n,o,i=null;if(e.Pn>=0){let p=e.u[e.Pn];if(!p)return;t=p.layout,n=p.pipeline.xLevels,o=p.pipeline.yLevels,i=p.label}else{if(!e.l)return;t=e.l,n=e.Ot,o=e.Vt}let r=e.Ge,s={px:e.zi,py:e.Xi},a=[];i&&a.push(i);let l=ol(n,r.xIdx),u=ol(o,r.yIdx);l&&a.push(l),u&&a.push(u);let m=e.getColumnFormatter(e.I[0],\"value\");a.push(`Value: ${m(r.value)}`);let f=e.A();Pe(e.c,s,a,t,f,e.t?.dpr??1)}var Pr={skipLeafLevel:!0};function il(e,t){let n=t.gl,o=t.dpr,i=n.canvas.width/o,r=n.canvas.height/o;if(i<=0||r<=0)return;if(e.u.length>0){Tf(e,t,i,r);return}if(e.At===0||e.Lt===0)return;let s=e.A(),a={levels:e.Ot,numRows:e.At,levelLabels:e._.slice()},l={levels:e.Vt,numRows:e.Lt,levelLabels:[]},u=e.En.mode===\"numeric\",m=e.Gn.mode===\"numeric\",f=m?55:el(l,Pr),p=u?24:We(a,Math.max(1,i-f-110)),d=new ne(i,r,{hasXLabel:e._.length>0,hasYLabel:!1,hasLegend:!0,bottomExtra:p,leftExtra:f});e.l=d,e.g&&e.g.updateLayout(d);let b=u?e.ft.min:-.5,x=u?e.ft.max:e.At-.5,h=m?e.ct.min:-.5,g=m?e.ct.max:e.Lt-.5;e.g&&e.g.setBaseDomain(b,x,h,g);let y=e.g?e.g.getVisibleDomain():{xMin:b,xMax:x,yMin:h,yMax:g},_=d.buildProjectionMatrix(y.xMin,y.xMax,y.yMin,y.yMax,void 0,void 0,0,e.w,e.M),C=d.e,v=C.width/(y.xMax-y.xMin),A=C.height/(y.yMax-y.yMin),T=s.Mi*.5,L=u?e.ft.bandWidth:1,R=m?e.ct.bandWidth:1,F=Math.min(L*.5,v>0?T/v:0),I=Math.min(R*.5,A>0?T/A:0);if(e.j){let S=ue(e.j,d,t.dpr)}rl(e,t),sl(e,t),e.oe=rn(t,e.oe,s.H),ze(n,d,t.dpr,()=>{n.useProgram(e.o);let S=e.F;n.uniformMatrix4fv(S.u_projection,!1,_),n.uniform2f(S.u_cell_inset,F,I),n.uniform2f(S.u_cell_size,L,R),Ge(t,e.oe.texture,S.u_gradient_lut,0),al(e,n,t,0,e.$i)}),e.pe(()=>ci(e))}function rl(e,t){if(e.o)return;let n=t.gl,o=j(t,\"heatmap\",On,Vn,[\"u_projection\",\"u_cell_inset\",\"u_cell_size\",\"u_gradient_lut\"],[\"a_corner\",\"a_cell\",\"a_color_t\"]);e.o=o.program,e.F=o;let i=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),e.k=i}function sl(e,t){let n=e.Qe.length;if(e.$i=n,n===0)return;let o=new Float32Array(n*2),i=new Float32Array(n);if(e.u.length>0){let r=0;for(let s of e.u){let a=s.pipeline.xPositions,l=s.pipeline.yPositions,u=s.xOrigin,m=s.yOrigin;for(let f of s.pipeline.cells)o[r*2]=a?a[f.xIdx]-u:f.xIdx,o[r*2+1]=l?l[f.yIdx]-m:f.yIdx,i[r]=rt(f.value,e.b,e.p),r++}}else{let r=e.Dn,s=e.Bn,a=e.w,l=e.M;for(let u=0;u<n;u++){let m=e.Qe[u];o[u*2]=r?r[m.xIdx]-a:m.xIdx,o[u*2+1]=s?s[m.yIdx]-l:m.yIdx,i[u]=rt(m.value,e.b,e.p)}}t.v.ensureCapacity(n),t.v.upload(\"heatmap_cell\",o,0,2),t.v.upload(\"heatmap_t\",i,0,1)}function al(e,t,n,o,i){if(i===0)return;let r=e.F,s=J(n),{setDivisor:a}=s,l=Float32Array.BYTES_PER_ELEMENT;t.bindBuffer(t.ARRAY_BUFFER,e.k),t.enableVertexAttribArray(r.a_corner),t.vertexAttribPointer(r.a_corner,2,t.FLOAT,!1,0,0),a(r.a_corner,0);let u=n.v.peek(\"heatmap_cell\"),m=n.v.peek(\"heatmap_t\");!u||!m||(t.bindBuffer(t.ARRAY_BUFFER,u.buffer),t.enableVertexAttribArray(r.a_cell),t.vertexAttribPointer(r.a_cell,2,t.FLOAT,!1,0,o*2*l),a(r.a_cell,1),t.bindBuffer(t.ARRAY_BUFFER,m.buffer),t.enableVertexAttribArray(r.a_color_t),t.vertexAttribPointer(r.a_color_t,1,t.FLOAT,!1,0,o*l),a(r.a_color_t,1),s.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,i),a(r.a_cell,0),a(r.a_color_t,0))}function ci(e){if(!e.c)return;if(e.u.length>0){Rf(e);return}if(!e.l)return;let t=e.l,n=e.A(),o=e.t?.dpr??1,i=ue(e.c,t,o);if(!i)return;i.strokeStyle=n.un,i.lineWidth=1,i.beginPath(),i.moveTo(t.e.x,t.e.y),i.lineTo(t.e.x,t.e.y+t.e.height),i.lineTo(t.e.x+t.e.width,t.e.y+t.e.height),i.stroke();let r={levels:e.Ot,numRows:e.At,levelLabels:e._.slice()},s={levels:e.Vt,numRows:e.Lt,levelLabels:[]},a=e._[0],l=e._[1]??e.B[0];if(e.En.mode===\"numeric\"&&e.ft){let u=ie(t.Y,t.J,6);oi(i,t,e.ft,u,n,e.getColumnFormatter(a,\"tick\"))}else pe(i,t,r,n);if(e.Gn.mode===\"numeric\"&&e.ct){let u=ie(t.q,t.Q,6);ii(i,t,e.ct,u,n,e.getColumnFormatter(l,\"tick\"))}else Sr(i,t,s,n,Pr);St(e.c,t,{min:e.b,max:e.p,label:e.fi},n.H,n,e.getColumnFormatter(e.I[0],\"value\")),e.Ge&&Br(e)}function Tf(e,t,n,o){let i=t.gl,r=e.A(),{effectiveSharedX:s,effectiveSharedY:a}=e.computeEffectiveFacetFlags(),l=Re(e.u.map(m=>m.label),{cssWidth:n,cssHeight:o,xAxis:s?\"outer\":\"cell\",yAxis:a?\"outer\":\"cell\",hasLegend:!0,hasXLabel:e._.length>0,hasYLabel:!1,gap:8});e.m=l;for(let m=0;m<e.u.length;m++){let f=l.cells[m];f&&(e.u[m].layout=f.layout)}e.syncFacetZoomLayouts(l.cells),rl(e,t),sl(e,t),e.oe=rn(t,e.oe,r.H),i.useProgram(e.o);let u=e.F;Ge(t,e.oe.texture,u.u_gradient_lut,0),at(i);for(let m=0;m<e.u.length;m++){let f=e.u[m];if(f.instanceCount===0)continue;let{numX:p,numY:d}=f.pipeline;if(p===0||d===0)continue;let b=f.layout,x=f.pipeline.xAxisMode.mode===\"numeric\",h=f.pipeline.yAxisMode.mode===\"numeric\",g=x?f.pipeline.xNumericDomain.min:-.5,y=x?f.pipeline.xNumericDomain.max:p-.5,_=h?f.pipeline.yNumericDomain.min:-.5,C=h?f.pipeline.yNumericDomain.max:d-.5,v=e.getZoomControllerForFacet(m);v&&v.setBaseDomain(g,y,_,C);let A=v?v.getVisibleDomain():{xMin:g,xMax:y,yMin:_,yMax:C},T=b.buildProjectionMatrix(A.xMin,A.xMax,A.yMin,A.yMax,void 0,void 0,0,f.xOrigin,f.yOrigin),L=b.e,R=L.width/(A.xMax-A.xMin),F=L.height/(A.yMax-A.yMin),I=r.Mi*.5,S=x?f.pipeline.xNumericDomain.bandWidth:1,D=h?f.pipeline.yNumericDomain.bandWidth:1,B=Math.min(S*.5,R>0?I/R:0),N=Math.min(D*.5,F>0?I/F:0);lt(i,b,t.dpr,()=>{i.uniformMatrix4fv(u.u_projection,!1,T),i.uniform2f(u.u_cell_inset,B,N),i.uniform2f(u.u_cell_size,S,D),al(e,i,t,f.instanceStart,f.instanceCount)})}e.pe(()=>ci(e))}function Rf(e){if(!e.c||!e.m)return;let t=e.A(),n=e.t?.dpr??1,o=ue(e.c,e.u[0].layout,n);if(!o)return;let i=e.eo,r=e.to,s=e.m;for(let a=0;a<e.u.length;a++){let l=e.u[a],u=s.cells[a],m=l.layout,f=m.e;o.strokeStyle=t.un,o.lineWidth=1,o.beginPath(),o.moveTo(f.x,f.y),o.lineTo(f.x,f.y+f.height),o.lineTo(f.x+f.width,f.y+f.height),o.stroke();let p={levels:l.pipeline.xLevels,numRows:l.pipeline.numX,levelLabels:e._.slice()},d={levels:l.pipeline.yLevels,numRows:l.pipeline.numY,levelLabels:[]},b=e._[0],x=e._[1]??e.B[0];if(!i||u.isBottomEdge)if(l.pipeline.xAxisMode.mode===\"numeric\"&&l.pipeline.xNumericDomain){let h=ie(m.Y,m.J,6);oi(o,m,l.pipeline.xNumericDomain,h,t,e.getColumnFormatter(b,\"tick\"))}else pe(o,m,p,t);if(!r||u.isLeftEdge)if(l.pipeline.yAxisMode.mode===\"numeric\"&&l.pipeline.yNumericDomain){let h=ie(m.q,m.Q,6);ii(o,m,l.pipeline.yNumericDomain,h,t,e.getColumnFormatter(x,\"tick\"))}else Sr(o,m,d,t,Pr)}for(let a=0;a<s.cells.length;a++){let l=s.cells[a],u=e.u[a];!u||!l.titleRect||_t(e.c,u.label,l.titleRect,t,n)}s.legendRect&&mn(e.c,{x:s.legendRect.x,y:s.legendRect.y+20,width:s.legendRect.width,height:Math.max(1,s.legendRect.height-20)},{min:e.b,max:e.p,label:\"\"},t.H,t,e.getColumnFormatter(e.I[0],\"value\")),e.Ge&&Br(e)}var di=class extends Te{constructor(){super(...arguments);c(this,\"o\",null);c(this,\"F\",null);c(this,\"k\",null);c(this,\"oe\",null);c(this,\"Ot\",[]);c(this,\"Vt\",[]);c(this,\"ci\",[]);c(this,\"At\",0);c(this,\"Lt\",0);c(this,\"mt\",0);c(this,\"En\",{mode:\"category\"});c(this,\"Gn\",{mode:\"category\"});c(this,\"Dn\",null);c(this,\"Bn\",null);c(this,\"ft\",null);c(this,\"ct\",null);c(this,\"w\",0);c(this,\"M\",0);c(this,\"Qe\",[]);c(this,\"wo\",[]);c(this,\"$i\",0);c(this,\"b\",0);c(this,\"p\",1);c(this,\"fi\",\"\");c(this,\"Ge\",null);c(this,\"l\",null);c(this,\"zi\",0);c(this,\"Xi\",0);c(this,\"u\",[]);c(this,\"m\",null);c(this,\"Pn\",-1);c(this,\"mi\",()=>ci(this))}tooltipCallbacks(){return{onHover:(n,o)=>Dr(this,n,o),onLeave:()=>{this.Ge&&(this.Ge=null,this.mi())},onPin:(n,o)=>{Dr(this,n,o),this.Ge&&this.rr(this.Ge.xIdx,this.Ge.yIdx)},onUnpin:()=>{this.emitUnselect()}}}async rr(n,o){let i=this.Ot.map(a=>a.labels[n]??null),r=this.Vt.slice(0,this.B.length).map(a=>a.labels[o]??null),s=this.I[0]??\"\";await this.emitClickAndSelect({rowIdx:n+this.mt,columnName:s,groupByValues:i,splitByValues:r})}async uploadAndRender(n,o,i,r){if(this.t=n,i!==0)return;let s=this.I.filter(a=>!!a);if(s.length>1){let a=Ja(o,s),l=[],u=[],m=1/0,f=-1/0;for(let p of a){let d=Rr({columns:p.columns,numRows:r,groupBy:this._,splitBy:this.B,groupByTypes:this.ht}),b=u.length;for(let x of d.cells)u.push({xIdx:x.xIdx,yIdx:x.yIdx,value:x.value});l.push({label:p.label,pipeline:d,layout:new ne(1,1,{hasXLabel:!1,hasYLabel:!1,hasLegend:!1}),instanceStart:b,instanceCount:d.cells.length,xOrigin:d.xNumericDomain?.min??0,yOrigin:d.yNumericDomain?.min??0}),isFinite(d.colorMin)&&d.colorMin<m&&(m=d.colorMin),isFinite(d.colorMax)&&d.colorMax>f&&(f=d.colorMax)}!isFinite(m)||!isFinite(f)?(m=0,f=1):m===f&&(f=m+1),this.Ot=[],this.Vt=[],this.ci=[],this.At=0,this.Lt=0,this.mt=0,this.wo=[],this.l=null,this.En={mode:\"category\"},this.Gn={mode:\"category\"},this.Dn=null,this.Bn=null,this.ft=null,this.ct=null,this.w=0,this.M=0,this.u=l,this.Qe=u,this.b=m,this.p=f,this.fi=s.join(\", \")}else{let a=Rr({columns:o,numRows:r,groupBy:this._,splitBy:this.B,groupByTypes:this.ht});this.u=[],this.m=null,this.Ot=a.xLevels,this.Vt=a.yLevels,this.ci=a.yColumnNames,this.At=a.numX,this.Lt=a.numY,this.mt=a.rowOffset,this.Qe=a.cells,this.wo=a.cells2D,this.b=a.colorMin,this.p=a.colorMax,this.fi=s[0]??\"Color\",this.En=a.xAxisMode,this.Gn=a.yAxisMode,this.Dn=a.xPositions,this.Bn=a.yPositions,this.ft=a.xNumericDomain,this.ct=a.yNumericDomain,this.w=a.xNumericDomain?.min??0,this.M=a.yNumericDomain?.min??0}await this.requestRender(n)}Dt(n){this.t=n;let o=this.At>0&&this.Lt>0,i=this.u.length>0;!o&&!i||il(this,n)}destroyInternal(){this.k&&this.t&&this.t.gl.deleteBuffer(this.k),this.o=null,this.F=null,this.k=null,this.Ot=[],this.Vt=[],this.ci=[],this.Qe=[],this.wo=[],this.Ge=null,this.u=[],this.m=null,this.Pn=-1,this.En={mode:\"category\"},this.Gn={mode:\"category\"},this.Dn=null,this.Bn=null,this.ft=null,this.ct=null}};Qt();function Tn(){return{count:0,catIdx:new Int32Array(0),splitIdx:new Int32Array(0),seriesId:new Int32Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),open:new Float64Array(0),close:new Float64Array(0),high:new Float64Array(0),low:new Float64Array(0),isUp:new Uint8Array(0)}}function wf(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),splitIdx:new Int32Array(t),seriesId:new Int32Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),open:new Float64Array(t),close:new Float64Array(t),high:new Float64Array(t),low:new Float64Array(t),isUp:new Uint8Array(t)}}var ll={splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:{mode:\"category\"},numericCategoryDomain:null,categoryPositions:null,series:[],yDomain:{min:0,max:1}};function ul(e){let{columns:t,numRows:n,columnSlots:o,groupBy:i,splitBy:r,groupByTypes:s,bandInnerFrac:a,barInnerPad:l,scratchCandles:u}=e,m=Gt(i,s),f=o[0]||\"\";if(!f)return{...ll,candles:Tn()};let p=o[1]||\"\",d=o[2]||\"\",b=o[3]||\"\",x=[];if(r.length>0){let O=[f];p&&O.push(p),d&&O.push(d),b&&O.push(b);for(let X of He(t,[f],O))X.colNames.has(f)&&x.push(X.prefix);x.length===0&&x.push(\"\")}else x.push(\"\");let h=i.map(O=>s[O]??\"string\"),{rowPaths:g,numCategories:y,rowOffset:_}=Wt(t,n,i.length,h);if(y===0)return{...ll,axisMode:m,splitPrefixes:x,rowPaths:g,rowOffset:_,candles:Tn()};let C=x.length,v=[];for(let O=0;O<C;O++){let X=x[O];v.push({seriesId:O,splitIdx:O,splitKey:X,label:X===\"\"?f:X})}let A=null,T=null,L=1;if(m.mode===\"numeric\"&&y>0){let O=t.get(\"__ROW_PATH_0__\"),X=ct(O?.values,y,_,i[0]??\"\",m.numericType===\"date\"||m.numericType===\"datetime\");X&&(A=X.categoryPositions,T=X.numericCategoryDomain,L=X.numericCategoryDomain.bandWidth)}let R=Ko(C,a,l),F=R.slotWidth*L,I=R.halfWidth*L,S=(C-1)/2,D=[];for(let O=0;O<C;O++){let X=x[O],q=et=>X===\"\"?et:`${X}|${et}`,le=t.get(q(f));if(!le?.values){D.push({openCol:null,closeCol:null,highCol:null,lowCol:null,openValid:null,closeValid:null,highValid:null,lowValid:null});continue}let Fe=p?t.get(q(p)):null,_e=d?t.get(q(d)):null,ve=b?t.get(q(b)):null;D.push({openCol:le.values,closeCol:Fe?.values??null,highCol:_e?.values??null,lowCol:ve?.values??null,openValid:le.valid??null,closeValid:Fe?.valid??null,highValid:_e?.valid??null,lowValid:ve?.valid??null})}let B=y*C,N=wf(u??null,B),k=0,Y=1/0,W=-1/0,V=y;for(let O=0;O<C;O++){let X=D[O],q=X.openCol;if(!q)continue;let le=X.closeCol,Fe=X.highCol,_e=X.lowCol,ve=X.openValid,et=X.closeValid,zt=X.highValid,Xt=X.lowValid,$t=(O-S)*F;for(let ge=0;ge<V;ge++){let se=ge+_;if(ve&&!(ve[se>>3]>>(se&7)&1))continue;let Q=q[se];if(!isFinite(Q))continue;let oe;if(le&&(!et||(et[se>>3]>>(se&7)&1)!==0)){let K=le[se];oe=isFinite(K)?K:Q}else{let K=ge<V-1?ge+1+_:se;if(!ve||(ve[K>>3]>>(K&7)&1)!==0){let bt=q[K];oe=isFinite(bt)?bt:Q}else oe=Q}let Se;if(Fe&&(!zt||(zt[se>>3]>>(se&7)&1)!==0)){let K=Fe[se];Se=isFinite(K)?K:Q>oe?Q:oe}else Se=Q>oe?Q:oe;let Ie;if(_e&&(!Xt||(Xt[se>>3]>>(se&7)&1)!==0)){let K=_e[se];Ie=isFinite(K)?K:Q<oe?Q:oe}else Ie=Q<oe?Q:oe;let Ai=(A?A[ge]:ge)+$t,De=oe>=Q?1:0;N.catIdx[k]=ge,N.splitIdx[k]=O,N.seriesId[k]=O,N.xCenter[k]=Ai,N.halfWidth[k]=I,N.open[k]=Q,N.close[k]=oe,N.high[k]=Se,N.low[k]=Ie,N.isUp[k]=De,k++,Ie<Y&&(Y=Ie),Se>W&&(W=Se)}}if(N.count=k,!isFinite(Y)||!isFinite(W))Y=0,W=1;else if(Y===W){let O=Math.max(Math.abs(Y),1)*.05;Y-=O,W+=O}return{splitPrefixes:x,rowPaths:g,numCategories:y,rowOffset:_,axisMode:m,numericCategoryDomain:T,categoryPositions:A,series:v,candles:N,yDomain:{min:Y,max:W}}}Ye();Ee();on();Ct();Ae();Ft();var Mf=3;function ml(e,t,n){let o=0,i=t;for(;o<i;){let r=o+i>>>1;e[r]<n?o=r+1:i=r}return o}function Er(e,t,n){if(e.di!==-1)return;let o=e.l;if(!o)return;let i=e.Ce;if(i.count===0){e._e!==-1&&(e._e=-1,Qe(e));return}let r=o.e,s=o.Y,a=o.J,l=o.q,u=o.Q;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){e._e!==-1&&(e._e=-1,Qe(e));return}let m=s+(t-r.x)/r.width*(a-s),f=u-(n-r.y)/r.height*(u-l),p=r.width/(a-s),d=Mf/p,b=i.xCenter,x=i.halfWidth,h=i.open,g=i.close,y=i.high,_=i.low,C=i.count>0?x[0]:0,v=Math.max(C,d),A=ml(b,i.count,m-v),T=ml(b,i.count,m+v+1e-12),L=-1;for(let R=T-1;R>=A;R--){let F=b[R],I=x[R],S=m>=F-I&&m<=F+I,D=Math.abs(m-F)<=d;if(!S&&!D)continue;let B=h[R],N=g[R],k=B<N?B:N,Y=B<N?N:B,W=S&&f>=k&&f<=Y,V=f>=_[R]&&f<=y[R];if(W||V){L=R;break}}L!==e._e&&(e._e=L,Qe(e))}function fl(e,t){e.T.dismiss(),e.di=t;let n=e.Ce;if(t<0||t>=n.count||!e.l)return;let o=Gr(e,t);if(o.length===0)return;let i=n.xCenter[t],r=(n.high[t]+n.low[t])/2,s=e.l.P(i,r),a=e.l.cssWidth,l=e.l.cssHeight;e.T.pin(o,s,{cssWidth:a,cssHeight:l}),e._e=-1,Qe(e)}function Gr(e,t){let n=[],o=e.Ce;if(t<0||t>=o.count)return n;let i=o.catIdx[t],r=o.splitIdx[t],s=o.open[t],a=o.close[t],l=o.high[t],u=o.low[t];if(e.Ke===\"numeric\"&&e.D&&e.qe){let b=e.qe[i],x=e._[0];n.push(e.getColumnFormatter(x,\"value\")(b))}else if(e.we.length>0){let b=[];for(let x of e.we){let h=x.labels[i]??\"\";h&&b.push(h)}b.length>0&&n.push(b.join(\" \\u203A \"))}else n.push(`Row ${i+e.mt}`);if(r>=0&&e.fe.length>1){let b=e.fe[r];b&&n.push(b)}let m=e.getColumnFormatter(e.I[0],\"value\"),f=e.getColumnFormatter(e.I[1],\"value\"),p=e.getColumnFormatter(e.I[2],\"value\"),d=e.getColumnFormatter(e.I[3],\"value\");return n.push(`Open: ${m(s)}`),n.push(`Close: ${f(a)}`),n.push(`High: ${p(l)}`),n.push(`Low: ${d(u)}`),n}function cl(e,t,n,o,i){let r=1/0,s=-1/0,a={cat:0,lo:0,hi:0,skip:!1};for(let u=0;u<e.length;u++)a.skip=!1,o(e[u],a),!a.skip&&(a.cat<t||a.cat>n||(a.lo<r&&(r=a.lo),a.hi>s&&(s=a.hi)));let l=isFinite(r)&&isFinite(s);if(l&&r===s){let u=Math.abs(r)||1;r-=u,s+=u}return i.min=r,i.max=s,i.hasFit=l,i}function Wr(e){let n=e.A().H;if(e.Mo===n)return;let o=Le(n,1),i=Le(n,0);e.Fo=[o[0],o[1],o[2]],e.So=[i[0],i[1],i[2]],e.Mo=n}function dl(e){e.N.bodyWick.invalidateBuffers(e),e.N.ohlc.invalidateBuffers(e)}function pl(e,t){e.N.bodyWick.rebuildBuffers(e,t),e.N.ohlc.rebuildBuffers(e,t)}function bl(e,t){let n=t.gl,o=t.dpr,i=n.canvas.width/o,r=n.canvas.height/o;if(i<=0||r<=0||e.ee===0)return;let s=e.A();Wr(e);let a=e.Ke===\"numeric\",l=a?e.D.min:-.5,u=a?e.D.max:e.ee-.5;e.g&&e.g.setBaseDomain(l,u,e.Wn.min,e.Wn.max);let m=e.g?e.g.getVisibleDomain():{xMin:l,xMax:u,yMin:e.Wn.min,yMax:e.Wn.max};if(e.io&&e.g&&!e.g.isXDefault()){let _=Sf(e,m.xMin,m.xMax);_.hasFit&&(m.yMin=_.min,m.yMax=_.max)}let f=e._.length>0,p={levels:e.we,numRows:e.ee,levelLabels:e._.slice()},d;if(a)d=new ne(i,r,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:24});else{let v=Math.max(1,i-71-16),A=We(p,v);d=new ne(i,r,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:A})}e.l=d,e.g&&e.g.updateLayout(d);let b=d.buildProjectionMatrix(m.xMin,m.xMax,m.yMin,m.yMax,\"y\",void 0,void 0,e.se,0),x=ie(m.yMin,m.yMax,6),h=e.I[0]||\"\",g=p,y={min:m.yMin,max:m.yMax,label:h};e.j&&si(e.j,d,x,s,t.dpr),ze(n,d,t.dpr,()=>{e.no===\"ohlc\"?e.N.ohlc.draw(e,n,t,b):e.N.bodyWick.draw(e,n,t,b)}),e.he=g,e.xe=y,e.Re=x,e.ze=a?ie(m.xMin,m.xMax,6):null,e.pe(()=>Qe(e))}function Qe(e){if(!e.c||!e.l||!e.xe||!e.Re)return;let t=e.A(),n;if(e.Ke===\"numeric\"&&e.D&&e.ze)n={mode:\"numeric\",domain:{min:e.D.min,max:e.D.max,isDate:e.D.isDate,label:e.D.label},ticks:e.ze};else if(e.he)n={mode:\"category\",domain:e.he};else return;let o=e.I[0]??e.I[1]??e.I[2]??e.I[3],i=e._[0];ri(e.c,n,{mode:\"numeric\",domain:e.xe,ticks:e.Re},e.l,t,e.t?.dpr??1,void 0,!1,{value:e.getColumnFormatter(o,\"tick\"),category:e.getColumnFormatter(i,\"tick\")}),e._e>=0&&e._e<e.Ce.count&&Ff(e)}function Ff(e){if(!e.c||!e.l)return;let t=e._e,n=e.Ce;if(t<0||t>=n.count)return;let o=e.l,i=n.xCenter[t],r=(n.high[t]+n.low[t])/2,s=o.P(i,r),a=Gr(e,t),l=e.A();Pe(e.c,s,a,o,l,e.t?.dpr??1,{crosshair:!1,highlightRadius:0})}function Sf(e,t,n){let o=e._t;if(o&&o.xMin===t&&o.xMax===n)return o;let i=o??If();i.xMin=t,i.xMax=n;let r=e.Ce,s=1/0,a=-1/0,l=!1,u=r.xCenter,m=r.low,f=r.high;for(let p=0;p<r.count;p++){let d=u[p];d<t||d>n||(m[p]<s&&(s=m[p]),f[p]>a&&(a=f[p]),l=!0)}return i.min=l?s:0,i.max=l?a:1,i.hasFit=l,e._t=i,i}function If(){return{xMin:0,xMax:0,min:0,max:1,hasFit:!1}}Me();fe();var pi=class{constructor(){c(this,\"o\",null);c(this,\"i\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,o=Lo(n),r={...j(t,\"candlestick-body\",Nn,Un,[\"u_projection\"],[\"a_corner\",\"a_x_center\",\"a_half_width\",\"a_y0\",\"a_y1\",\"a_color\"]),quadBuffer:o,instanceBuffer:n.createBuffer()},s=je(n),l={...j(t,\"line-uniform\",Oe,Ve,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_corner\",\"a_start\",\"a_end\",\"a_real_start\",\"a_real_end\"]),cornerBuffer:s,segmentBuffer:n.createBuffer()};return this.o={body:r,wick:l},this.o}invalidateBuffers(t){let n=this.i;if(!n||!t.t){this.i=null;return}let o=t.t.gl;o.deleteBuffer(n.upWickBuffer),o.deleteBuffer(n.downWickBuffer),this.i=null}rebuildBuffers(t,n){let o=t.Ce,i=this.ensureProgram(n),r=n.gl,s=t.se;if(o.count===0){let F=r.createBuffer(),I=r.createBuffer();this.i={bodyCount:0,upWickCount:0,downWickCount:0,upWickBuffer:F,downWickBuffer:I};return}let a=new Float32Array(o.count*7),l=0,u=0,m=o.xCenter,f=o.halfWidth,p=o.open,d=o.close,b=o.isUp,x=t.Fo,h=t.So;for(let F=0;F<o.count;F++){let I=p[F],S=d[F],D=I<S?I:S,B=I<S?S:I,N=b[F]!==0,k=N?x:h,Y=F*7;a[Y+0]=m[F]-s,a[Y+1]=f[F]*.7,a[Y+2]=D,a[Y+3]=B,a[Y+4]=k[0],a[Y+5]=k[1],a[Y+6]=k[2],N?l++:u++}r.bindBuffer(r.ARRAY_BUFFER,i.body.instanceBuffer),r.bufferData(r.ARRAY_BUFFER,a,r.STATIC_DRAW);let g=new Float32Array(l*4),y=new Float32Array(u*4),_=0,C=0,v=o.low,A=o.high;for(let F=0;F<o.count;F++){let I=m[F]-s,S=v[F],D=A[F];b[F]!==0?(g[_+0]=I,g[_+1]=S,g[_+2]=I,g[_+3]=D,_+=4):(y[C+0]=I,y[C+1]=S,y[C+2]=I,y[C+3]=D,C+=4)}let T=this.i,L=T?.upWickBuffer??r.createBuffer(),R=T?.downWickBuffer??r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,L),r.bufferData(r.ARRAY_BUFFER,g,r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,R),r.bufferData(r.ARRAY_BUFFER,y,r.STATIC_DRAW),this.i={bodyCount:o.count,upWickCount:l,downWickCount:u,upWickBuffer:L,downWickBuffer:R}}draw(t,n,o,i){let r=this.i;if(!r||r.bodyCount===0)return;let s=this.ensureProgram(o);Df(n,o,s.body,r.bodyCount,i),Bf(t,n,o,s.wick,r,i)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let o=this.o;o&&(n.deleteBuffer(o.body.quadBuffer),n.deleteBuffer(o.body.instanceBuffer),n.deleteBuffer(o.wick.cornerBuffer),n.deleteBuffer(o.wick.segmentBuffer))}this.o=null,this.i=null}};function Df(e,t,n,o,i){if(o===0)return;let r=7*Float32Array.BYTES_PER_ELEMENT;e.useProgram(n.program),e.uniformMatrix4fv(n.u_projection,!1,i);let s=J(t),{setDivisor:a}=s;e.bindBuffer(e.ARRAY_BUFFER,n.quadBuffer),e.enableVertexAttribArray(n.a_corner),e.vertexAttribPointer(n.a_corner,2,e.FLOAT,!1,0,0),a(n.a_corner,0),e.bindBuffer(e.ARRAY_BUFFER,n.instanceBuffer);let l=Float32Array.BYTES_PER_ELEMENT,u=(m,f,p)=>{e.enableVertexAttribArray(m),e.vertexAttribPointer(m,f,e.FLOAT,!1,r,p),a(m,1)};u(n.a_x_center,1,0),u(n.a_half_width,1,1*l),u(n.a_y0,1,2*l),u(n.a_y1,1,3*l),u(n.a_color,3,4*l),s.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,o),a(n.a_x_center,0),a(n.a_half_width,0),a(n.a_y0,0),a(n.a_y1,0),a(n.a_color,0)}function Bf(e,t,n,o,i,r){if(i.upWickCount===0&&i.downWickCount===0)return;let s=n.dpr;t.useProgram(o.program),t.uniformMatrix4fv(o.u_projection,!1,r),t.uniform2f(o.u_resolution,t.canvas.width,t.canvas.height),t.uniform1f(o.u_line_width,e.h.wick_width_px*s),t.disableVertexAttribArray(o.a_real_start),t.disableVertexAttribArray(o.a_real_end),t.vertexAttrib1f(o.a_real_start,1),t.vertexAttrib1f(o.a_real_end,1),t.uniform1f(o.u_interp_alpha,1);let a=J(n),{setDivisor:l}=a;t.bindBuffer(t.ARRAY_BUFFER,o.cornerBuffer),t.enableVertexAttribArray(o.a_corner),t.vertexAttribPointer(o.a_corner,1,t.FLOAT,!1,0,0),l(o.a_corner,0),gl(t,a,o,i.upWickBuffer,i.upWickCount,e.Fo),gl(t,a,o,i.downWickBuffer,i.downWickCount,e.So),l(o.a_start,0),l(o.a_end,0)}function gl(e,t,n,o,i,r){if(i===0)return;let s=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:a}=t;e.uniform4f(n.u_color,r[0],r[1],r[2],1),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,2*s,0),a(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,2*s,s),a(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,i)}Me();fe();var bi=class{constructor(){c(this,\"o\",null);c(this,\"i\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,o=je(n),i=j(t,\"line-uniform\",Oe,Ve,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_corner\",\"a_start\",\"a_end\",\"a_real_start\",\"a_real_end\"]);return this.o={...i,cornerBuffer:o,segmentBuffer:n.createBuffer()},this.o}invalidateBuffers(t){let n=this.i;if(!n||!t.t){this.i=null;return}let o=t.t.gl;o.deleteBuffer(n.upBuffer),o.deleteBuffer(n.downBuffer),this.i=null}rebuildBuffers(t,n){if(t.no!==\"ohlc\")return;let o=t.Ce,i=n.gl;this.ensureProgram(n);let r=t.se,s=o.xCenter,a=o.halfWidth,l=o.open,u=o.close,m=o.high,f=o.low,p=o.isUp,d=0,b=0;for(let A=0;A<o.count;A++)p[A]!==0?d++:b++;let x=new Float32Array(d*3*4),h=new Float32Array(b*3*4),g=0,y=0;for(let A=0;A<o.count;A++){let T=s[A]-r,L=l[A],R=u[A],F=f[A],I=m[A],S=a[A],D=p[A]!==0?x:h,B=p[A]!==0?g:y;D[B++]=T,D[B++]=F,D[B++]=T,D[B++]=I,D[B++]=T-S,D[B++]=L,D[B++]=T,D[B++]=L,D[B++]=T,D[B++]=R,D[B++]=T+S,D[B++]=R,p[A]!==0?g=B:y=B}let _=this.i,C=_?.upBuffer??i.createBuffer(),v=_?.downBuffer??i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,C),i.bufferData(i.ARRAY_BUFFER,x,i.STATIC_DRAW),i.bindBuffer(i.ARRAY_BUFFER,v),i.bufferData(i.ARRAY_BUFFER,h,i.STATIC_DRAW),this.i={upBuffer:C,downBuffer:v,upInstanceCount:d*3,downInstanceCount:b*3}}draw(t,n,o,i){let r=this.i;if(!r||r.upInstanceCount===0&&r.downInstanceCount===0)return;let s=this.ensureProgram(o),a=o.dpr;n.useProgram(s.program),n.uniformMatrix4fv(s.u_projection,!1,i),n.uniform2f(s.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(s.u_line_width,t.h.ohlc_line_width_px*a),n.disableVertexAttribArray(s.a_real_start),n.disableVertexAttribArray(s.a_real_end),n.vertexAttrib1f(s.a_real_start,1),n.vertexAttrib1f(s.a_real_end,1),n.uniform1f(s.u_interp_alpha,1);let l=J(o),{setDivisor:u}=l;n.bindBuffer(n.ARRAY_BUFFER,s.cornerBuffer),n.enableVertexAttribArray(s.a_corner),n.vertexAttribPointer(s.a_corner,1,n.FLOAT,!1,0,0),u(s.a_corner,0),hl(n,l,s,r.upBuffer,r.upInstanceCount,t.Fo),hl(n,l,s,r.downBuffer,r.downInstanceCount,t.So),u(s.a_start,0),u(s.a_end,0)}destroy(t){let n=t.t?.gl;if(n){this.invalidateBuffers(t);let o=this.o;o&&(n.deleteBuffer(o.cornerBuffer),n.deleteBuffer(o.segmentBuffer))}this.o=null,this.i=null}};function hl(e,t,n,o,i,r){if(i===0)return;let s=4*Float32Array.BYTES_PER_ELEMENT,a=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:l}=t;e.uniform4f(n.u_color,r[0],r[1],r[2],1),e.bindBuffer(e.ARRAY_BUFFER,o),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,s,0),l(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,s,a),l(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,i)}var Rn=class extends Nt{constructor(){super(...arguments);c(this,\"F\",null);c(this,\"fe\",[]);c(this,\"s\",[]);c(this,\"Ce\",Tn());c(this,\"Wn\",{min:0,max:1});c(this,\"Io\",null);c(this,\"Ke\",\"category\");c(this,\"D\",null);c(this,\"qe\",null);c(this,\"ze\",null);c(this,\"se\",0);c(this,\"Fo\",[0,.8,.4]);c(this,\"So\",[.8,.2,.2]);c(this,\"Mo\",null);c(this,\"_e\",-1);c(this,\"di\",-1);c(this,\"N\",{bodyWick:new pi,ohlc:new bi});c(this,\"io\",!0);c(this,\"_t\",null)}tooltipCallbacks(){return{onHover:(n,o)=>Er(this,n,o),onLeave:()=>{this._e!==-1&&(this._e=-1,Qe(this))},onPin:(n,o)=>{if(Er(this,n,o),this._e>=0){let i=this._e;fl(this,i),this.sr(i)}},onUnpin:()=>{this.emitUnselect()}}}async sr(n){if(n<0||n>=this.Ce.count)return;let o=this.Ce.catIdx[n],i=this.Ce.splitIdx[n],r=this.we.map(u=>u.labels[o]??null),s=this.fe[i]??\"\",a=this.B.length>0&&s!==\"\"?s.split(\"|\"):[],l=this.I[1]||this.I.find(u=>!!u)||\"\";await this.emitClickAndSelect({rowIdx:o+this.mt,columnName:l,groupByValues:r,splitByValues:a})}invalidateTheme(){super.invalidateTheme(),this.Mo=null}async uploadAndRender(n,o,i,r){if(this.t=n,i!==0)return;let s=ul({columns:o,numRows:r,columnSlots:this.I,groupBy:this._,splitBy:this.B,groupByTypes:this.ht,bandInnerFrac:this.h.band_inner_frac,barInnerPad:this.h.bar_inner_pad,scratchCandles:this.Ce});this.h.domain_mode===\"expand\"?this.Io=Ln(this.Io,s.yDomain):this.Io=null,this.we=s.rowPaths,this.ee=s.numCategories,this.mt=s.rowOffset,this.fe=s.splitPrefixes,this.s=s.series,this.Ce=s.candles,this.Wn=s.yDomain,this.Ke=s.axisMode.mode,this.D=s.numericCategoryDomain,this.qe=s.categoryPositions,this.se=s.numericCategoryDomain?.min??0,this._t=null,Wr(this),dl(this),pl(this,n),await this.requestRender(n)}Dt(n){this.t=n,bl(this,n)}resetExpandedDomain(){this.Io=null}destroyInternal(){if(this.t){let n=this.t.gl;this.k&&n.deleteBuffer(this.k),this.N.bodyWick.destroy(this),this.N.ohlc.destroy(this)}this.o=null,this.F=null,this.k=null,this.Ce=Tn(),this.s=[],this.we=[],this.ee=0,this.Mo=null}};var wl={scatter:async()=>To,line:async()=>Ro,density:async()=>wo,treemap:async()=>Xo,sunburst:async()=>qo,heatmap:async()=>di,\"y-bar\":async()=>Je,\"y-line\":async()=>Je,\"y-scatter\":async()=>Je,\"y-area\":async()=>Je,\"x-bar\":async()=>fi,candlestick:async()=>Rn,ohlc:async()=>Rn,\"map-scatter\":async()=>(await Promise.resolve().then(()=>(Ci(),yi))).MapScatterChart,\"map-line\":async()=>(await Promise.resolve().then(()=>(Ci(),yi))).MapLineChart,\"map-density\":async()=>(await Promise.resolve().then(()=>(Ci(),yi))).MapDensityChart};async function Ml(e,t,n){let o=new Map;await e.with_typed_arrays(n??{},async(i,r,s,a)=>{for(let u=0;u<i.length;u++){let m=i[u],f=r[u],p=s[u]??void 0,d=a[u];d!==null?o.set(m,{type:\"string\",indices:f,dictionary:d,valid:p}):f instanceof Float32Array?o.set(m,{type:\"float32\",values:f,valid:p}):f instanceof Int32Array?o.set(m,{type:\"int32\",values:f,valid:p}):f instanceof Float64Array?o.set(m,{type:\"float64\",values:f,valid:p}):o.set(m,{type:\"float32\",values:new Float32Array(f),valid:p})}let l=0;if(o.size>0){l=1/0;for(let u of o.values()){let m=u.indices?.length??u.values?.length??0;m<l&&(l=m)}}await t(o,l)})}var Fl=new Map;async function Sl(e){let t=[e.family,e.src,e.weight??\"\",e.style??\"\"].join(\"|\"),n=Fl.get(t);if(n){await n;return}n=(async()=>{try{let o={};e.style&&(o.style=e.style),e.weight&&(o.weight=e.weight),e.stretch&&(o.stretch=e.stretch);let i=new FontFace(e.family,e.src,o);await i.load(),self.fonts.add(i)}catch(o){console.warn(`Failed to load font ${e.family}:`,o)}})(),Fl.set(t,n),await n}function Yt(e,t){switch(t.kind){case\"setViewByName\":e.setViewByName(t.name);break;case\"setColumnsConfig\":e.chartImpl.setColumnsConfig?.(t.cfg);break;case\"setPluginConfig\":e.chartImpl.setPluginConfig?.(t.cfg),e.redraw();break;case\"setBufferMaxCapacity\":e.glManager.v.maxCapacity=t.n;break;case\"loadAndRender\":e.loadAndRender(t);break;case\"redraw\":e.redraw();break;case\"deselect\":e.chartImpl.deselect?.();break;case\"resize\":e.resize(t.cssWidth,t.cssHeight,t.dpr),e.redrawAck(t.msgId);break;case\"clear\":e.clear();break;case\"invalidateTheme\":e.chartImpl.setTheme?.(t.themeVars),e.chartImpl.invalidateTheme?.(),e.resize(e.cssWidth,e.cssHeight,e.dpr);break;case\"restoreZoom\":e.restoreZoom(t.state);break;case\"resetAllZooms\":e.resetAllZooms(),e.redraw(),e.post({kind:\"zoomChanged\",isDefault:e.allZoomsDefault()});break;case\"resetExpandedDomain\":e.resetExpandedDomain();break;case\"interaction\":e.onInteraction(t.event);break;case\"saveZoom\":e.post({kind:\"saveZoomReply\",requestId:t.requestId,state:e.saveZoom()});break;case\"destroy\":e.destroy();break;case\"init\":break;case\"snapshotPng\":{let n=t.requestId;e.snapshotPng().then(o=>{e.post({kind:\"snapshotPngReply\",requestId:n,blob:o})}).catch(o=>{e.post({kind:\"error\",message:String(o)})});break}}}var Mn=new Map,Hr=new Set;function Yr(e,t,n){let o={sessionId:e,msg:t};n&&n.length>0?self.postMessage(o,n):self.postMessage(o)}function Wf(e){return{postMessage:(t,n)=>Yr(e,t,n),addEventListener:()=>{},removeEventListener:()=>{},start:()=>{},close:()=>{},dispatchEvent:()=>!1,onmessage:null,onmessageerror:null}}function Il(e){self.addEventListener(\"message\",function(t){let n=t.data,{sessionId:o,msg:i}=n;if(i.kind===\"init\"){if(Mn.has(o)){Yr(o,{kind:\"error\",message:`sessionId ${o} already initialized`});return}e(i,Wf(o)).then(s=>{if(Hr.delete(o)){Yt(s,{kind:\"destroy\"});return}Mn.set(o,s)}).catch(s=>{Hr.delete(o),Yr(o,{kind:\"error\",message:String(s)})});return}if(i.kind===\"destroy\"){let s=Mn.get(o);s?(Yt(s,i),Mn.delete(o)):Hr.add(o);return}let r=Mn.get(o);r&&Yt(r,i)})}Ui();var _i=class extends Error{constructor(){super(\"StaleGenerationError\")}};async function Bl(e){let t=wl[e];if(!t)throw new Error(`Unknown chart tag: ${e}`);return await t()}var zr=null;function kf(e){return zr||(zr=new Qn(4,{precompile:e})),zr}var vi=class{constructor(t,n,o,i,r,s){c(this,\"chartImpl\");c(this,\"glManager\");c(this,\"zoomController\",null);c(this,\"gridlines\");c(this,\"chrome\");c(this,\"cssWidth\");c(this,\"cssHeight\");c(this,\"dpr\");c(this,\"client\");c(this,\"view\");c(this,\"table\");c(this,\"controlPort\");c(this,\"pi\",0);c(this,\"Do\",null);c(this,\"bi\",0);c(this,\"gi\",0);if(this.client=n,this.view=o,this.table=i,this.controlPort=r,this.chartImpl=new s,t.renderMode===\"blit\"&&!t.glCanvas&&!0)this.glManager=new qt(kf(t.precompileShaders??!1).acquire());else{let l=t.glCanvas??new OffscreenCanvas(Math.max(1,Math.round(t.cssWidth*t.dpr)),Math.max(1,Math.round(t.cssHeight*t.dpr)));this.glManager=new qt(l,{precompile:t.precompileShaders??!1})}t.renderMode===\"blit\"&&this.glManager.setFrameCallback(l=>{this.post({kind:\"frameBitmap\",bitmap:l},[l])}),this.gridlines=t.gridlinesCanvas,this.chrome=t.chromeCanvas,this.cssWidth=t.cssWidth,this.cssHeight=t.cssHeight,this.dpr=t.dpr,this.chartImpl.setGridlineCanvas?.(t.gridlinesCanvas),this.chartImpl.setChromeCanvas?.(t.chromeCanvas),this.chartImpl.setTheme?.(t.themeVars),t.defaultChartType&&this.chartImpl.setDefaultChartType?.(t.defaultChartType),this.chartImpl.setFacetConfig?.(t.facetConfig),this.chartImpl.setPluginConfig?.(t.pluginConfig),t.columnsConfig&&this.chartImpl.setColumnsConfig?.(t.columnsConfig),this.chartImpl.setZoomController&&(this.zoomController=new yt,this.chartImpl.setZoomController(this.zoomController)),this.chartImpl.setView?.(o),this.glManager.v.maxCapacity=t.bufferMaxCapacity,this.glManager.resize(t.cssWidth,t.cssHeight,t.dpr),this.chartImpl.attachTooltip?.(new to(l=>this.post(l)))}setViewByName(t){this.view=this.client.__unsafe_open_view(t),this.chartImpl.setView?.(this.view)}async loadAndRender(t){let n=++this.pi;try{let[o,i,r,s]=await Promise.all([this.view.num_rows(),this.view.schema(),this.view.expression_schema(),this.table?.schema()??Promise.resolve({})]);if(this.pi!==n)return;this.chartImpl.setViewPivots?.(t.viewerConfig.group_by,t.viewerConfig.split_by),this.chartImpl.setColumnTypes?.(i),this.chartImpl.setGroupByTypes?.({...s,...r}),this.chartImpl.setColumnSlots?.(t.viewerConfig.columns);let a=Object.keys(i).length||1,l=Math.floor(this.glManager.v.maxCapacity/a),u=Math.min(o,l);this.glManager.ensureBufferCapacity(u);try{await Ml(this.view,async(m,f)=>{if(this.pi!==n)throw new _i;await this.chartImpl.uploadAndRender(this.glManager,m,0,Math.min(u,f))},{end_row:u,float32:t.options.float32})}catch(m){if(!(m instanceof _i))throw m}}catch(o){(o+\"\").indexOf(\"View not found\")===-1&&console.error(\"loadAndRender failed\",o)}finally{this.post({kind:\"loadAndRenderAck\",msgId:t.msgId})}}redraw(){this.chartImpl.requestRender(this.glManager)}redrawAck(t){this.chartImpl.requestRender(this.glManager).catch(()=>{}).finally(()=>this.post({kind:\"resizeAck\",msgId:t}))}resize(t,n,o){this.cssWidth=t,this.cssHeight=n,this.dpr=o,this.glManager.requestResize(t,n,o),this.chartImpl.requestRender(this.glManager)}clear(){Cs(this.glManager,()=>{this.glManager.clear(),this.gridlines.getContext(\"2d\")?.clearRect(0,0,this.gridlines.width,this.gridlines.height)})}saveZoom(){return this.zoomController?.serialize()}restoreZoom(t){t&&this.zoomController?.restore(t)}allZoomsDefault(){if(this.zoomController&&!this.zoomController.isDefault())return!1;let t=this.chartImpl?.cn;if(t){for(let n of t)if(n&&!n.isDefault())return!1}return!0}resetAllZooms(){this.zoomController?.reset();let t=this.chartImpl?.cn;if(t)for(let n of t)n?.reset();this.resetExpandedDomain()}resetExpandedDomain(){this.chartImpl.resetExpandedDomain?.()}Qi(t,n){let o=this.chartImpl,i=o?.m;if(i){for(let a=0;a<i.cells.length;a++){let l=i.cells[a],u=l.layout.e;if(t>=u.x&&t<=u.x+u.width&&n>=u.y&&n<=u.y+u.height){let m=o.getZoomControllerForFacet?.(a)??this.zoomController;return m?{controller:m,layout:l.layout}:null}}return null}if(!this.zoomController)return null;let r=o?.l;if(!r)return null;let s=r.e;return t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height?null:{controller:this.zoomController,layout:r}}onInteraction(t){switch(t.type){case\"wheel\":{let n=this.Qi(t.mx,t.my);if(!n)return;ts(n,t.mx,t.my,t.deltaY),this.chartImpl.requestRender(this.glManager),this.post({kind:\"zoomChanged\",isDefault:this.allZoomsDefault()});break}case\"pointerdown\":{let n=this.Qi(t.mx,t.my);if(!n)return;this.Do=n,this.bi=t.mx,this.gi=t.my;break}case\"pointermove\":{if(this.Do){let n=t.mx-this.bi,o=t.my-this.gi;this.bi=t.mx,this.gi=t.my,ns(this.Do,n,o),this.chartImpl.requestRender(this.glManager),this.post({kind:\"zoomChanged\",isDefault:this.allZoomsDefault()})}else this.T()?.dispatchHover(t.mx,t.my);break}case\"pointerup\":{this.Do=null;break}case\"pointerleave\":{this.T()?.dispatchLeave();break}case\"click\":{this.T()?.dispatchClick(t.mx,t.my);break}case\"dblclick\":{this.T()?.dispatchDblClick(t.mx,t.my);break}}}T(){return this.chartImpl?.T??null}async snapshotPng(){this.glManager.beginFrame(),this.chartImpl.renderFrameSync(this.glManager);let t=this.glManager.gl,n=t.canvas,o=n.width,i=n.height,r=new Uint8ClampedArray(o*i*4);t.readPixels(0,0,o,i,t.RGBA,t.UNSIGNED_BYTE,r);let s=new OffscreenCanvas(o,i),a=s.getContext(\"2d\");if(!a)throw new Error(\"snapshotPng: 2D context unavailable\");let u=this.chartImpl.A?.()?.backgroundColor??\"transparent\";u!==\"transparent\"&&(a.fillStyle=u,a.fillRect(0,0,o,i)),a.drawImage(this.gridlines,0,0);let m=new OffscreenCanvas(o,i),f=m.getContext(\"2d\");if(!f)throw new Error(\"snapshotPng: 2D context unavailable for GL blit\");return f.putImageData(new ImageData(r,o,i),0,0),a.save(),a.scale(1,-1),a.drawImage(m,0,-i),a.restore(),a.drawImage(this.chrome,0,0),await s.convertToBlob({type:\"image/png\"})}destroy(){_s(this.glManager),this.chartImpl.destroy(),this.glManager.destroy()}post(t,n){n&&n.length>0?this.controlPort.postMessage(t,n):this.controlPort.postMessage(t)}},Nf=typeof globalThis.importScripts==\"function\";async function Uf(e,t){if(!e.clientWorkerURL||!e.clientWasm||!e.proxyPort)throw new Error(\"Init error\");let n=await import(e.clientWorkerURL.toString());await n.initSync({module:e.clientWasm}),e.fontFaces?.length&&await Promise.all(e.fontFaces.map(Sl));let o=e.proxyPort,i=new n.Client(async u=>{let m=u.slice().buffer;o.postMessage(m,[m])},async()=>o.close());o.addEventListener(\"message\",u=>{i.handle_response(new Uint8Array(u.data))}),o.start();let r=i.__unsafe_open_view(e.viewName),s=e.tableName?await i.open_table(e.tableName):null,a=await Bl(e.chartTag),l=new vi(e,i,r,s,t,a);return l.post({kind:\"ready\"}),l}async function TC(e){let t=e.client.__unsafe_open_view(e.msg.viewName),n=e.msg.tableName?await e.client.open_table(e.msg.tableName):null,o=await Bl(e.msg.chartTag),i=new vi(e.msg,e.client,t,n,e.controlPort,o);return e.controlPort.addEventListener(\"message\",r=>{let s=r.data;s?.kind!==\"init\"&&Yt(i,s)}),e.controlPort.start(),i.post({kind:\"ready\"}),i}Nf&&Il(Uf);export{vi as WorkerRenderer,TC as bootstrapInProcess};\n", "\n import workerSource from \"../worker/renderer.worker.js\";\n let cached = null;\n export async function getWorkerURL() {\n if (cached) return cached;\n const blob = new Blob([workerSource], {\n type: \"application/javascript\",\n });\n\n cached = URL.createObjectURL(blob);\n return cached;\n }\n\n function make_host(a, b) {\n return {\n addEventListener(type, callback) {\n if (type === \"message\") {\n a.push(callback);\n }\n },\n removeEventListener(type, callback) {\n const idx = a.indexOf(callback);\n if (idx > -1) {\n a.splice(idx, 1);\n }\n },\n postMessage(msg, ports) {\n for (const listener of b) {\n listener({\n data: msg,\n ports: ports,\n });\n }\n },\n terminate() {},\n location: { href: \"\" },\n };\n }\n\n function run_single_threaded() {\n console.warn(\n \"Running perspective in single-threaded mode\"\n );\n const f = Function(\n \"const self = arguments[0];\" + workerSource\n );\n const workers = [];\n const mains = [];\n f(make_host(workers, mains));\n return make_host(mains, workers);\n }\n\n export async function initialize(opts) {\n const workerOpts = opts || {\n type: \"module\",\n };\n try {\n if (\n typeof window !== \"undefined\" &&\n window.location &&\n window.location.protocol &&\n window.location.protocol.startsWith(\n \"file\"\n )\n ) {\n console.warn(\n \"file:// protocol does not reliably support Web Workers\"\n );\n return run_single_threaded();\n }\n\n const url = await getWorkerURL();\n const worker = new Worker(url, workerOpts);\n return worker;\n } catch (e) {\n console.error(\n \"Error instantiating worker; falling back to single-threaded mode\",\n e\n );\n return run_single_threaded();\n }\n }\n\n export default getWorkerURL;\n ", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Client, View, ViewConfig } from \"@perspective-dev/client\";\nimport type { FacetConfig, PluginConfig } from \"../charts/chart\";\nimport type {\n ControlMsg,\n InitMsg,\n InteractionEvent,\n LoadAndRenderMsg,\n WorkerEnvelope,\n WorkerMsg,\n} from \"./protocol\";\nimport {\n PerspectiveSelectDetail,\n type PerspectiveClickDetail,\n} from \"../event-detail\";\nimport { snapshotThemeVars } from \"../theme/theme-snapshot\";\nimport { snapshotFontFaces } from \"../utils/font-snapshot\";\nimport { DomHostSink } from \"../interaction/host-sink-dom\";\nimport { RUNTIME_MODE } from \"../config\";\n\n// @ts-ignore \u2014 resolved at build time by `@perspective-dev/esbuild-plugin/worker`\nimport getWorkerURL from \"../worker/renderer.worker.js\";\n\n/**\n * Module-level shared `Worker` for every `RendererTransport` running\n * in worker mode. One worker process hosts one `WorkerRenderer` per\n * active `sessionId` \u2014 N chart instances share startup costs (wasm\n * `initSync`, font loads, JS module parse) instead of paying them N\n * times.\n *\n * Lazy: created on first `transport.init()` in worker mode. Lives\n * until page teardown \u2014 no refcount, no termination logic. Pages\n * with no charts never spawn one. Per-session memory still scales\n * with N (each session retains its own WebGL context, buffer pool,\n * chart impl, view, client); the browser's ~16-context-per-worker\n * cap is the new ceiling on simultaneous worker-mode charts.\n *\n * In-process mode bypasses this entirely \u2014 each transport gets its\n * own `MessageChannel` + in-thread `WorkerRenderer`.\n */\nlet SHARED_WORKER: Promise<Worker> | null = null;\n\n/**\n * Per-session message handlers, keyed by the host-allocated\n * `sessionId`. The shared worker's response listener demultiplexes\n * incoming envelopes into here.\n */\nconst HOST_LISTENERS = new Map<number, (msg: WorkerMsg) => void>();\n\nlet NEXT_SESSION_ID = 0;\n\nasync function getSharedWorker(): Promise<Worker> {\n if (SHARED_WORKER) {\n return SHARED_WORKER;\n }\n\n SHARED_WORKER = (async () => {\n const url = await getWorkerURL();\n const w = new Worker(url, { type: \"module\", name: \"viewer-charts\" });\n w.addEventListener(\"message\", (e: MessageEvent) => {\n const env = e.data as WorkerEnvelope;\n HOST_LISTENERS.get(env.sessionId)?.(env.msg);\n });\n return w;\n })();\n\n return SHARED_WORKER;\n}\n\ninterface RendererHandle {\n post(msg: any, transfer: Transferable[]): void;\n addMessageListener(cb: (msg: any) => void): void;\n terminate(): void;\n}\n\ntype PendingRenderType =\n | \"saveZoom\"\n | \"loadAndRender\"\n | \"snapshotPng\"\n | \"resize\";\ninterface PendingRenderRequest {\n kind: PendingRenderType;\n resolve: (v: any) => void;\n reject: (e: Error) => void;\n}\n\n/**\n * Unified host-side driver for the chart renderer. Owns one of two\n * handle shapes:\n *\n * - **Worker mode**: a real `Worker` running the same module. The\n * handle posts `ControlMsg`s over `Worker.postMessage`.\n * - **In-process mode**: a `MessageChannel` whose `port2` is owned\n * by an in-thread `WorkerRenderer` instantiated via\n * `await import(workerURL)`. Same module bytes, different host.\n *\n * Both modes go through the same control channel, the same\n * `ProxySession` proxy port, and the same `OffscreenCanvas` transfer\n * \u2014 `MessageChannel` and `transferControlToOffscreen` work in-realm\n * just as well as cross-thread. The only branching is at construction\n * (handle creation) and bootstrap (worker scope sets up its own\n * `Client`; in-process reuses the host's).\n */\nexport class RendererTransport {\n private _handle: RendererHandle | null = null;\n\n /**\n * Set by {@link destroy}. Requests allocated after teardown settle\n * immediately in `_allocPending` \u2014 `_post` is already a no-op once\n * `_handle` is null, so a late request would otherwise never\n * receive its reply and pend forever.\n */\n private _destroyed = false;\n private _proxyChannel: MessageChannel | null = null;\n private _proxySession: any = null;\n private _client: Client;\n private _view: View;\n private _tableName: string | undefined;\n /** Source panel `slot`, tagged onto dispatched interaction events so the\n * host can route them (master/detail, global filter) to the right panel. */\n private _panel: string | undefined;\n private _clientWorkerURL: URL;\n private _clientWasm: WebAssembly.Module;\n private _chartTag: string;\n private _maxCells: number;\n private _precompileShaders: boolean;\n private _ready: Promise<void>;\n private _resolveReady!: () => void;\n private _rejectReady!: (err: Error) => void;\n\n /**\n * Pending request/reply promises across all worker round-trips \u2014\n * `saveZoom`, `uploadChunk` ACKs, and `snapshotPng`. Each entry\n * carries its `kind` so `destroy()` can apply per-kind teardown\n * semantics (uploadChunk resolves silently, the rest reject with\n * a teardown error).\n *\n * Keyed by a single monotonic counter; the worker's reply messages\n * carry that id back verbatim. One counter for all kinds is safe\n * because the host's switch already keys on `msg.kind` before\n * resolving.\n */\n private _pending = new Map<number, PendingRenderRequest>();\n\n private _pendingCounter = 0;\n private _onZoomChanged: ((isDefault: boolean) => void) | null = null;\n\n /**\n * Cached zoom-default flag pushed by the renderer after each zoom\n * mutation. Surfaced sync via `allZoomsDefault()`; updates between\n * calls are best-effort.\n */\n private _allZoomsDefault = true;\n private _hostGlCanvas: HTMLCanvasElement | null = null;\n\n /**\n * Blit-mode only: the visible `.webgl-canvas`'s 2D context. The\n * worker emits each completed GL frame as a `FrameBitmapMsg`; on\n * receipt we `drawImage` the bitmap into this context and `close()`\n * it to release the GPU surface. Null in direct mode (the visible\n * canvas's drawing buffer is the worker's transferred GL canvas).\n */\n private _displayCtx: CanvasRenderingContext2D | null = null;\n\n /**\n * Present-hold state for the staged-present presize protocol\n * ({@link presize}). While holding, inbound `frameBitmap`s are\n * STAGED (latest wins) instead of blitted, so the on-screen frame\n * \u2014 old dimensions in the old, unchanged box \u2014 stays put until the\n * host invokes the present closure `presize` resolved to, in the\n * same task as its layout commit. Entered only by `presize`;\n * exited by the present closure, by `presize`'s rejection path, or\n * by `destroy` \u2014 every settle path releases the hold or hands the\n * caller the release.\n */\n /**\n * The last `(cssWidth, cssHeight, dpr)` posted to the worker \u2014 at init\n * or any resize \u2014 i.e. the dimensions the worker has already rendered\n * (or has an in-flight render for). {@link resize} short-circuits when\n * its measurement matches (\u00B10.5px, the presize protocol's own\n * threshold): reactive resizes fan in from several host paths per\n * layout transition (the post-commit fan-out, activation nudges, the\n * fresh-restore tail), and every worker resize is an unconditional\n * full re-render.\n */\n private _lastPostedSize: {\n cssWidth: number;\n cssHeight: number;\n dpr: number;\n } | null = null;\n\n private _holdPresent = false;\n\n private _stagedFrame: ImageBitmap | null = null;\n\n /**\n * Host-side sink for tooltip + cursor side-effects. The chart\n * inside the renderer calls into a `MessageHostSink` that posts\n * `pinTooltip` / `dismissTooltip` / `setCursor` over the control\n * channel; this sink applies them to the DOM. Initialized lazily\n * on first signal so we don't pay for the parent-style lookup\n * unless a user interacts.\n */\n private _hostSink: DomHostSink | null = null;\n\n /**\n * Last `insertConfig` accepted by a `userSelect { selected: true }`\n * message. Used to populate `removeConfigs` on the next\n * `selected: false` (unpin / drill-up / view-change) \u2014 mirrors\n * datagrid's `model._last_insert_configs` so coordinated-filter\n * consumers can roll back the previous select when a new one\n * supplants it.\n */\n private _lastInsertConfig: Partial<ViewConfig> | undefined = undefined;\n\n constructor(opts: {\n client: Client;\n view: View;\n tableName?: string;\n panel?: string;\n clientWasm: WebAssembly.Module;\n clientWorkerURL: URL;\n chartTag: string;\n maxCells: number;\n precompileShaders?: boolean;\n onZoomChanged?: (isDefault: boolean) => void;\n }) {\n this._client = opts.client;\n this._view = opts.view;\n this._tableName = opts.tableName;\n this._panel = opts.panel;\n this._clientWorkerURL = opts.clientWorkerURL;\n this._clientWasm = opts.clientWasm;\n this._chartTag = opts.chartTag;\n this._maxCells = opts.maxCells;\n this._precompileShaders = opts.precompileShaders ?? false;\n this._onZoomChanged = opts.onZoomChanged ?? null;\n this._ready = new Promise((resolve, reject) => {\n this._resolveReady = resolve;\n this._rejectReady = reject;\n });\n }\n\n async init(opts: {\n gl: HTMLCanvasElement;\n gridlines: HTMLCanvasElement;\n chrome: HTMLCanvasElement;\n facetConfig: FacetConfig;\n pluginConfig: PluginConfig;\n columnsConfig?: Record<string, any>;\n defaultChartType?: string;\n renderBlitMode: \"blit\" | \"direct\";\n }): Promise<void> {\n this._hostGlCanvas = opts.gl;\n const workerURL: string = await getWorkerURL();\n\n // Worker mode: bridge the worker's fresh `Client` (instantiated\n // in `bootstrapWorker` from `clientWasm` + `clientWorkerURL`)\n // back to the host's real `Client` via a `ProxySession` over a\n // dedicated `MessageChannel`.\n //\n // In-process mode skips this entirely \u2014 `bootstrapInProcess`\n // is handed the host's `Client` directly, so there's no\n // worker-side `Client` to bridge. The proxy port would just\n // dangle.\n if (RUNTIME_MODE === \"worker\") {\n this._proxyChannel = new MessageChannel();\n this._proxySession = (this._client as any).new_proxy_session(\n (bytes: Uint8Array) => {\n const buf = bytes.slice().buffer;\n this._proxyChannel!.port1.postMessage(buf, [buf]);\n },\n );\n\n this._proxyChannel.port1.addEventListener(\n \"message\",\n (e: MessageEvent) => {\n this._proxySession.handle_request(new Uint8Array(e.data));\n },\n );\n\n this._proxyChannel.port1.start();\n }\n\n // Blit mode keeps the visible `.webgl-canvas` main-thread with\n // a 2D context \u2014 the renderer paints into its own internal\n // `OffscreenCanvas` and ships each completed frame back as an\n // `ImageBitmap`. Direct mode transfers the visible canvas's\n // drawing buffer to the renderer so GL paints straight to\n // screen.\n let glOC: OffscreenCanvas | undefined;\n if (opts.renderBlitMode === \"blit\") {\n this._displayCtx = opts.gl.getContext(\"2d\");\n } else {\n glOC = opts.gl.transferControlToOffscreen();\n }\n\n const gridlinesOC = opts.gridlines.transferControlToOffscreen();\n const chromeOC = opts.chrome.transferControlToOffscreen();\n const rect = opts.gl.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const themeVars = snapshotThemeVars(opts.gl);\n\n // Worker mode forwards `@font-face` rules so the worker's\n // separate `FontFaceSet` can resolve `ctx.font` family names.\n // In-process mode shares `document.fonts` with the host \u2014\n // omit the descriptors entirely.\n const fontFaces = RUNTIME_MODE === \"worker\" ? snapshotFontFaces() : [];\n const clientWasm =\n RUNTIME_MODE === \"worker\" ? this._clientWasm : undefined;\n\n const clientWorkerURL =\n RUNTIME_MODE === \"worker\" ? this._clientWorkerURL : undefined;\n\n const proxyPort =\n RUNTIME_MODE === \"worker\" ? this._proxyChannel!.port2 : undefined;\n\n const initMsg: InitMsg = {\n kind: \"init\",\n renderMode: opts.renderBlitMode,\n glCanvas: glOC,\n gridlinesCanvas: gridlinesOC,\n chromeCanvas: chromeOC,\n proxyPort,\n clientWorkerURL,\n clientWasm,\n chartTag: this._chartTag,\n viewName: this._view.__unsafe_get_name(),\n tableName: this._tableName,\n facetConfig: opts.facetConfig,\n pluginConfig: opts.pluginConfig,\n columnsConfig: opts.columnsConfig,\n defaultChartType: opts.defaultChartType,\n themeVars,\n fontFaces,\n cssWidth: rect.width,\n cssHeight: rect.height,\n dpr,\n bufferMaxCapacity: 0,\n precompileShaders: this._precompileShaders,\n };\n\n this._lastPostedSize = {\n cssWidth: rect.width,\n cssHeight: rect.height,\n dpr,\n };\n this._handle = await this._createHandle(workerURL, initMsg);\n this._handle.addMessageListener((msg) =>\n this._handleRendererMsg(msg as WorkerMsg),\n );\n\n if (RUNTIME_MODE === \"worker\") {\n // Worker mode: the bootstrap is triggered by posting the\n // init message into the worker's scope (which the\n // `if (IS_WORKER_SCOPE)` block in `renderer.worker.ts`\n // listens for). `glOC` is omitted in blit mode (the\n // renderer allocates its own offscreen) \u2014 only include the\n // GL canvas in the transfer list when present.\n const transfer: Transferable[] = [\n gridlinesOC,\n chromeOC,\n this._proxyChannel!.port2,\n ];\n if (glOC) {\n transfer.unshift(glOC);\n }\n\n this._handle.post(initMsg, transfer);\n }\n\n // In-process mode: the handle's `_createHandle` already kicked\n // off `bootstrapInProcess` with the init msg directly, no\n // postMessage needed.\n\n await this._ready;\n }\n\n /**\n * Construct the underlying transport. Worker mode wraps the\n * module-shared `Worker` (lazy, page-singleton) and tags every\n * message with a unique `sessionId`. In-process mode pairs a\n * `MessageChannel` with a dynamically-imported\n * {@link bootstrapInProcess}.\n */\n private async _createHandle(\n workerURL: string,\n initMsg: InitMsg,\n ): Promise<RendererHandle> {\n if (RUNTIME_MODE === \"worker\") {\n const w = await getSharedWorker();\n const sessionId = ++NEXT_SESSION_ID;\n return {\n post: (msg, transfer) =>\n w.postMessage({ sessionId, msg }, transfer),\n addMessageListener: (cb) => {\n HOST_LISTENERS.set(sessionId, cb);\n },\n terminate: () => {\n HOST_LISTENERS.delete(sessionId);\n // Don't terminate the underlying worker \u2014 other\n // sessions may still be live. Worker-side\n // `WorkerRenderer` cleanup is driven by the\n // `destroy` ControlMsg posted by the transport\n // before reaching here.\n },\n };\n }\n\n // In-process: instantiate the renderer on this thread by\n // dynamic-importing the same module the worker uses. The Blob\n // URL (or file URL in debug builds) loads as ESM, so module\n // dedup means only one copy of the chart code lives in\n // memory regardless of how many host elements use this mode.\n // `@vite-ignore` is harmless under esbuild (esbuild's parser\n // ignores it); some downstream bundlers honor it to suppress\n // a static-import warning on the dynamic URL.\n //\n // Hand the host's already-bound `Client` to the renderer via\n // `bootstrapInProcess` \u2014 option B. The dynamically-imported\n // module has its own copy of the perspective-viewer\n // wasm-bindgen JS, but that copy stays unused: we never\n // construct `new Client(...)` inside it; we only ever call\n // methods on the host-supplied instance.\n const mod: any = await import(/* @vite-ignore */ workerURL);\n const channel = new MessageChannel();\n await mod.bootstrapInProcess({\n msg: initMsg,\n client: this._client,\n controlPort: channel.port2,\n });\n\n return {\n post: (msg, transfer) => channel.port1.postMessage(msg, transfer),\n addMessageListener: (cb) => {\n // `addEventListener(\"message\", \u2026)` does NOT auto-start\n // a `MessagePort` \u2014 only setting `onmessage` does.\n // Without this explicit `start()` the renderer's\n // `{ kind: \"ready\" }` would queue on `port1` forever\n // and `init()` would hang on `await this._ready`.\n channel.port1.addEventListener(\"message\", (e: MessageEvent) =>\n cb(e.data),\n );\n channel.port1.start();\n },\n terminate: () => {\n channel.port1.close();\n channel.port2.close();\n },\n };\n }\n\n setView(view: View): void {\n this._view = view;\n this._post({\n kind: \"setViewByName\",\n name: this._view.__unsafe_get_name(),\n });\n }\n\n setColumnsConfig(cfg: Record<string, any>): void {\n this._post({ kind: \"setColumnsConfig\", cfg });\n }\n\n setPluginConfig(cfg: PluginConfig): void {\n this._post({ kind: \"setPluginConfig\", cfg });\n }\n\n setBufferMaxCapacity(n: number): void {\n this._post({ kind: \"setBufferMaxCapacity\", n });\n }\n\n /**\n * Trigger a worker-side data fetch + render cycle. The worker\n * resolves all schema / row-count metadata against its own `View`\n * and `Table`, runs `view.with_typed_arrays`, and pipes the\n * resulting `ColumnDataMap` directly into `chartImpl.uploadAndRender`\n * \u2014 no host-side `Client`/`Table`/`View` await, no `postMessage` of\n * column buffers.\n *\n * The returned promise resolves when the worker replies with\n * `loadAndRenderAck`. Per the worker's \"resolve on stale\"\n * contract, a mid-flight cancellation (a newer `loadAndRender`\n * superseding this one) still acks \u2014 the host's awaiter just\n * resolves quietly. Calls issued after `destroy()` resolve\n * immediately (see `_allocPending`).\n */\n loadAndRender(opts: {\n viewerConfig: {\n group_by: string[];\n split_by: string[];\n columns: (string | null)[];\n };\n options?: { float32?: boolean };\n }): Promise<void> {\n const { id, promise } = this._allocPending<void>(\"loadAndRender\");\n const msg: LoadAndRenderMsg = {\n kind: \"loadAndRender\",\n msgId: id,\n viewerConfig: opts.viewerConfig,\n options: { float32: opts.options?.float32 ?? true },\n };\n\n this._post(msg);\n return promise;\n }\n\n redraw(): void {\n this._post({ kind: \"redraw\" });\n }\n\n /**\n * Silently clear the worker chart's selection state (pinned tooltip) \u2014\n * no selection events are emitted; the worker echoes `dismissTooltip`\n * to drop the host-side pinned artifact. See `DeselectMsg`.\n */\n deselect(): void {\n this._post({ kind: \"deselect\" });\n }\n\n /**\n * Resize the chart to the GL canvas's CURRENT CSS box and resolve\n * once the resized frame has PRESENTED (the worker's `resizeAck`) \u2014\n * not at message-post, which would let callers proceed while the\n * old-dimensions bitmap is still on screen. Reactive geometry\n * changes only; anticipated ones go through {@link presize}.\n *\n * A measurement matching {@link _lastPostedSize} resolves immediately\n * WITHOUT a worker round trip: the worker has already rendered (or is\n * presenting) that exact frame, and re-posting would be a full\n * re-render of an identical bitmap.\n */\n resize(): Promise<void> {\n if (!this._hostGlCanvas) {\n return Promise.resolve();\n }\n\n const rect = this._hostGlCanvas.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const last = this._lastPostedSize;\n if (\n last &&\n Math.abs(last.cssWidth - rect.width) <= 0.5 &&\n Math.abs(last.cssHeight - rect.height) <= 0.5 &&\n last.dpr === dpr\n ) {\n return Promise.resolve();\n }\n\n return this._postResize(rect.width, rect.height);\n }\n\n /**\n * Staged-present variant of {@link resize}: render at the given\n * TARGET canvas CSS box (no measurement \u2014 the caller supplies the\n * box the pending layout commit will produce), HOLDING the\n * resulting frame (and any others that arrive meanwhile) offscreen\n * instead of blitting, so nothing on screen changes. Resolves,\n * once the resized frame is staged, to a present closure: calling\n * it blits the latest staged frame and exits the hold \u2014 the host\n * runs it in the same task as its layout commit so geometry and\n * pixels land in one paint. On rejection (teardown) the hold is\n * released here, so every settle path either frees the display or\n * hands the caller the release.\n */\n presize(cssWidth: number, cssHeight: number): Promise<(() => void) | void> {\n if (!this._hostGlCanvas) {\n return Promise.resolve();\n }\n\n const dpr = window.devicePixelRatio || 1;\n const last = this._lastPostedSize;\n if (\n last &&\n Math.abs(last.cssWidth - cssWidth) <= 0.5 &&\n Math.abs(last.cssHeight - cssHeight) <= 0.5 &&\n last.dpr === dpr\n ) {\n return Promise.resolve();\n }\n\n this._holdPresent = true;\n return this._postResize(cssWidth, cssHeight).then(\n () => () => this._presentStaged(),\n (err) => {\n this._presentStaged();\n throw err;\n },\n );\n }\n\n private _postResize(cssWidth: number, cssHeight: number): Promise<void> {\n const dpr = window.devicePixelRatio || 1;\n const { id, promise } = this._allocPending<void>(\"resize\");\n this._lastPostedSize = { cssWidth, cssHeight, dpr };\n this._post({\n kind: \"resize\",\n msgId: id,\n cssWidth,\n cssHeight,\n dpr,\n });\n return promise;\n }\n\n private _presentStaged(): void {\n this._holdPresent = false;\n const staged = this._stagedFrame;\n this._stagedFrame = null;\n if (staged) {\n this._drawFrameBitmap(staged);\n }\n }\n\n clear() {\n this._post({ kind: \"clear\" });\n }\n\n invalidateTheme() {\n if (!this._hostGlCanvas) {\n return;\n }\n\n const themeVars = snapshotThemeVars(this._hostGlCanvas);\n this._post({ kind: \"invalidateTheme\", themeVars });\n }\n\n async saveZoom() {\n const { id } = this._allocPending<any>(\"saveZoom\");\n this._post({ kind: \"saveZoom\", requestId: id });\n }\n\n /**\n * Allocate a pending request slot of the given `kind`. Returns the\n * id (encoded into the outgoing `ControlMsg`) and a promise that\n * resolves / rejects when the matching reply arrives or\n * `destroy()` drains the table. Requests issued *after* `destroy()`\n * settle immediately with the same per-kind semantics as the drain.\n */\n private _allocPending<T>(kind: PendingRenderType): {\n id: number;\n promise: Promise<T>;\n } {\n // A request issued after `destroy()` would never settle: `_post`\n // no-ops with no handle, so no reply ever lands \u2014 and the host\n // awaits `loadAndRender` while holding its per-renderer draw\n // lock, so a pending-forever promise wedges that panel's lock\n // permanently. (Reachable when an external DOM disconnect\n // `delete()`s the element mid-draw; the host's own teardown\n // paths are serialized behind the same lock.) Mirror the\n // `destroy()` drain: `loadAndRender` resolves silently,\n // reply-bearing kinds reject. The pre-attached no-op `catch`\n // marks the rejection handled for fire-and-forget callers\n // (`saveZoom`) without affecting real awaiters.\n if (this._destroyed) {\n if (kind === \"loadAndRender\") {\n return {\n id: -1,\n promise: Promise.resolve(undefined as unknown as T),\n };\n }\n\n const promise = Promise.reject<T>(\n new Error(\"RendererTransport destroyed\"),\n );\n promise.catch(() => {});\n return { id: -1, promise };\n }\n\n const id = ++this._pendingCounter;\n const promise = new Promise<T>((resolve, reject) => {\n this._pending.set(id, { kind, resolve, reject });\n });\n\n return { id, promise };\n }\n\n restoreZoom(state: any): void {\n this._post({ kind: \"restoreZoom\", state });\n }\n\n allZoomsDefault(): boolean {\n return this._allZoomsDefault;\n }\n\n resetAllZooms(): void {\n this._post({ kind: \"resetAllZooms\" });\n }\n\n resetExpandedDomain(): void {\n this._post({ kind: \"resetExpandedDomain\" });\n }\n\n /**\n * Request a PNG snapshot of the current frame. The worker flushes a\n * synchronous render across the GL + gridlines + chrome layers,\n * composites them into a single `OffscreenCanvas`, fills the theme\n * background, and replies with the `convertToBlob` result.\n */\n snapshotPng(): Promise<Blob> {\n const { id, promise } = this._allocPending<Blob>(\"snapshotPng\");\n this._post({ kind: \"snapshotPng\", requestId: id });\n return promise;\n }\n\n forwardInteraction(event: InteractionEvent): void {\n this._post({ kind: \"interaction\", event });\n }\n\n destroy(): void {\n this._destroyed = true;\n this._post({ kind: \"destroy\" });\n if (this._proxySession) {\n this._proxySession.close().catch(() => {});\n }\n\n if (this._proxyChannel) {\n this._proxyChannel.port1.close();\n this._proxyChannel = null;\n }\n\n if (this._handle) {\n this._handle.terminate();\n this._handle = null;\n }\n\n this._hostSink?.dismiss();\n this._hostSink = null;\n\n // The host's `<canvas>` elements are torn down by the plugin\n // element's `disconnectedCallback` after `destroy()` returns \u2014\n // null these refs now so any post-destroy code can't dereference\n // them, and so the GPU-backed 2D context can release earlier.\n this._hostGlCanvas = null;\n this._displayCtx = null;\n this._holdPresent = false;\n this._stagedFrame?.close();\n this._stagedFrame = null;\n\n // Drain pending request promises with kind-aware semantics:\n // - `loadAndRender` resolves silently (the host's awaited draw\n // observes a clean \"no more work\" rather than a teardown\n // rejection it would otherwise have to suppress).\n // - `saveZoom` / `snapshotPng` reject so the upstream promise\n // chain doesn't hang. Any unanswered messages still in the\n // worker's queue are abandoned along with the renderer when\n // the `destroy` ControlMsg fires worker-side.\n const teardownErr = new Error(\"RendererTransport destroyed\");\n for (const entry of this._pending.values()) {\n if (entry.kind === \"loadAndRender\") {\n entry.resolve(undefined);\n } else {\n entry.reject(teardownErr);\n }\n }\n\n this._pending.clear();\n }\n\n private _post(msg: ControlMsg): void {\n this._postRaw(msg, []);\n }\n\n private _postRaw(msg: ControlMsg, transfer: Transferable[]): void {\n if (!this._handle) {\n return;\n }\n\n this._handle.post(msg, transfer);\n }\n\n private _handleRendererMsg(msg: WorkerMsg): void {\n switch (msg.kind) {\n case \"ready\":\n this._resolveReady();\n break;\n case \"zoomChanged\":\n this._allZoomsDefault = msg.isDefault;\n this._onZoomChanged?.(msg.isDefault);\n break;\n case \"saveZoomReply\":\n this._resolvePending(msg.requestId, \"saveZoom\", msg.state);\n break;\n case \"pinTooltip\":\n this._ensureHostSink()?.pin(msg.lines, msg.pos, msg.bounds);\n break;\n case \"dismissTooltip\":\n this._hostSink?.dismiss();\n break;\n case \"setCursor\":\n this._ensureHostSink()?.setCursor(msg.cursor);\n break;\n case \"userClick\":\n this._dispatchOnViewer(\n new CustomEvent<PerspectiveClickDetail>(\n \"perspective-click\",\n {\n bubbles: true,\n composed: true,\n // Tag with the source panel so a multi-panel host\n // can attribute the click to the right panel.\n detail: { ...msg.detail, panel: this._panel },\n },\n ),\n );\n break;\n case \"userSelect\": {\n const removeConfigs = this._lastInsertConfig\n ? [this._lastInsertConfig]\n : [];\n const insertConfigs = msg.selected ? [msg.insertConfig] : [];\n this._lastInsertConfig = msg.selected\n ? msg.insertConfig\n : undefined;\n const detail = new PerspectiveSelectDetail(\n msg.selected,\n msg.row,\n msg.column_names,\n // `Partial<ViewConfig>` (what the chart emits) is\n // structurally a `ViewConfigUpdate` for the\n // `filter`-only patches we ship; the only\n // incompatible field (`group_by_depth: number |\n // null`) is never set by our emitters.\n removeConfigs as any,\n insertConfigs as any,\n );\n // Tag with the source panel so the host's master/detail +\n // global-filter routing can identify the originating panel.\n detail.panel = this._panel;\n this._dispatchOnViewer(\n new CustomEvent<PerspectiveSelectDetail>(\n \"perspective-global-filter\",\n {\n bubbles: true,\n composed: true,\n detail,\n },\n ),\n );\n break;\n }\n\n case \"frameBitmap\":\n if (this._holdPresent) {\n this._stagedFrame?.close();\n this._stagedFrame = msg.bitmap;\n } else {\n this._drawFrameBitmap(msg.bitmap);\n }\n\n break;\n case \"error\":\n this._rejectReady(new Error(msg.message));\n break;\n case \"loadAndRenderAck\":\n this._resolvePending(msg.msgId, \"loadAndRender\", undefined);\n break;\n case \"resizeAck\":\n this._resolvePending(msg.msgId, \"resize\", undefined);\n break;\n case \"snapshotPngReply\":\n this._resolvePending(msg.requestId, \"snapshotPng\", msg.blob);\n break;\n }\n }\n\n /**\n * Look up a pending request by id, verify the recorded kind\n * matches the inbound reply, resolve, and remove. Mismatches are\n * silently dropped \u2014 they would only fire if the worker echoed\n * the wrong kind for a given id, which would itself be a bug\n * worth catching at the worker side.\n */\n private _resolvePending(\n id: number,\n kind: PendingRenderType,\n value: unknown,\n ): void {\n const entry = this._pending.get(id);\n if (!entry || entry.kind !== kind) {\n return;\n }\n\n this._pending.delete(id);\n entry.resolve(value);\n }\n\n /**\n * Blit-mode handler: draw a renderer-emitted frame into the\n * visible 2D-context display canvas, then close the bitmap so its\n * GPU-backed surface is released. Resizes the visible canvas's\n * drawing buffer to the bitmap dimensions on first frame and\n * after any worker-side resize \u2014 the host doesn't directly\n * control GL canvas size in blit mode, so we follow whatever the\n * renderer emits.\n */\n private _drawFrameBitmap(bitmap: ImageBitmap): void {\n if (this._displayCtx && this._hostGlCanvas) {\n const w = bitmap.width;\n const h = bitmap.height;\n if (this._hostGlCanvas.width !== w) {\n this._hostGlCanvas.width = w;\n }\n\n if (this._hostGlCanvas.height !== h) {\n this._hostGlCanvas.height = h;\n }\n\n this._displayCtx.globalCompositeOperation = \"copy\";\n this._displayCtx.drawImage(bitmap, 0, 0);\n }\n\n bitmap.close();\n }\n\n /**\n * Dispatch a `CustomEvent` on the `<perspective-viewer>` ancestor\n * of this transport's GL canvas. Walks the parent chain so the\n * event bubbles from the viewer (matching where datagrid\n * dispatches its `perspective-click` / `perspective-global-filter`\n * events). No-op when the canvas is detached or no viewer ancestor\n * exists (test harnesses, snapshot mode).\n */\n private _dispatchOnViewer(ev: CustomEvent): void {\n if (!this._hostGlCanvas) {\n return;\n }\n\n let node: Node | null = this._hostGlCanvas;\n while (node) {\n if (\n node instanceof HTMLElement &&\n node.tagName === \"PERSPECTIVE-VIEWER\"\n ) {\n node.dispatchEvent(ev);\n return;\n }\n\n // Cross shadow-root boundaries \u2014 `parentNode` returns `null`\n // at a ShadowRoot, so use `host` when present.\n node =\n (node as ShadowRoot).host ??\n (node as Element).parentNode ??\n null;\n }\n }\n\n /**\n * Lazily construct a `DomHostSink` rooted at the host GL canvas\n * (cursor mutations) and its parent (pinned-tooltip `<div>`).\n * Returns `null` if the canvas has been detached.\n */\n private _ensureHostSink(): DomHostSink | null {\n if (this._hostSink) {\n return this._hostSink;\n }\n\n const parent = this._hostGlCanvas?.parentElement;\n if (!parent || !this._hostGlCanvas) {\n return null;\n }\n\n this._hostSink = new DomHostSink(this._hostGlCanvas, parent);\n return this._hostSink;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { View } from \"@perspective-dev/client\";\nimport type {\n HTMLPerspectiveViewerElement,\n IPerspectiveViewerPlugin,\n PluginStaticConfig,\n} from \"@perspective-dev/viewer\";\nimport { ChartTypeConfig, PluginConfigField } from \"./charts\";\nimport style from \"../../css/perspective-viewer-charts.css\";\nimport {\n DEFAULT_FACET_CONFIG,\n DEFAULT_PLUGIN_CONFIG,\n type FacetConfig,\n type PluginConfig,\n} from \"../charts/chart\";\nimport { RawEventForwarder } from \"../interaction/raw-event-forwarder\";\nimport { RendererTransport } from \"../transport/renderer-transport\";\nimport { RENDER_BLIT_MODE } from \"../config\";\n\n/**\n * Facet-rendering defaults shared by every chart. Per-chart overrides\n * arrive through `plugin_config` (`facet_mode` + `facet_zoom_mode`);\n * the remaining fields (`shared_x_axis`, `shared_y_axis`,\n * `coordinated_tooltip`, `facet_padding`) are not yet user-configurable\n * \u2014 flip the defaults in `DEFAULT_FACET_CONFIG` to change globally.\n */\nconst FACET_CONFIG_DEFAULTS: FacetConfig = { ...DEFAULT_FACET_CONFIG };\n\n/**\n * Static UI-control spec per `plugin_config` field. Mirrors the shape\n * `column_config_schema` already returns (datagrid). The runtime default\n * is sourced separately from the chart-type-effective defaults at\n * `fieldSpec` call time so per-chart overrides like\n * `include_zero=true` for Y Bar / Y Area / X Bar surface in the UI.\n */\ntype FieldSpec =\n | { kind: \"Bool\" }\n | {\n kind: \"Enum\";\n variants: ReadonlyArray<{ value: string; label: string }>;\n }\n | { kind: \"Number\"; min: number; max: number; step?: number };\n\nconst FIELD_SCHEMAS: Record<PluginConfigField, FieldSpec> = {\n auto_alt_y_axis: { kind: \"Bool\" },\n include_zero: { kind: \"Bool\" },\n domain_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"fit\", label: \"Fit\" },\n { value: \"expand\", label: \"Expand\" },\n ],\n },\n facet_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"grid\", label: \"Grid\" },\n { value: \"overlay\", label: \"Overlay\" },\n ],\n },\n facet_zoom_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"shared\", label: \"Shared\" },\n { value: \"independent\", label: \"Independent\" },\n ],\n },\n series_zoom_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"dynamic\", label: \"Dynamic\" },\n { value: \"fixed\", label: \"Fixed\" },\n ],\n },\n line_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 16 },\n point_size_px: { kind: \"Number\", min: 1, max: 32 },\n band_inner_frac: { kind: \"Number\", min: 0.1, max: 1, step: 0.01 },\n bar_inner_pad: { kind: \"Number\", min: 0, max: 0.9, step: 0.01 },\n wick_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 8 },\n ohlc_line_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 8 },\n gradient_radius_px: { kind: \"Number\", min: 2, step: 1, max: 256 },\n gradient_intensity: { kind: \"Number\", min: 0.05, step: 0.05, max: 4 },\n gradient_heat_max: { kind: \"Number\", min: 0.1, step: 0.1, max: 64 },\n gradient_color_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"mean\", label: \"Mean (density-weighted)\" },\n { value: \"density\", label: \"Density only\" },\n { value: \"extreme\", label: \"Extremes\" },\n { value: \"signed\", label: \"Signed sum\" },\n ],\n },\n map_tile_provider: {\n kind: \"Enum\",\n variants: [\n { value: \"carto-positron\", label: \"Light (Positron)\" },\n { value: \"carto-dark-matter\", label: \"Dark Matter\" },\n { value: \"carto-voyager\", label: \"Voyager\" },\n ],\n },\n map_tile_alpha: { kind: \"Number\", min: 0, max: 1, step: 0.05 },\n};\n\nfunction fieldSpec(\n key: PluginConfigField,\n defaults: PluginConfig,\n): Record<string, unknown> & { kind: string } {\n return { ...FIELD_SCHEMAS[key], key, default: defaults[key] };\n}\n\nconst GLOBAL_STYLES = (() => {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(style);\n return [sheet];\n})();\n\n/**\n * Process-global GL presentation strategy, shared by *every* chart-type\n * plugin in this renderer. Seeded from the build-time {@link RENDER_BLIT_MODE}\n * and overridable at runtime via\n * {@link HTMLPerspectiveViewerWebGLPluginElement.setBlitMode}.\n *\n * Module scope (not per-instance) on purpose: blit-vs-direct is a\n * whole-renderer decision \u2014 in `\"blit\"` mode the worker shares a pool of\n * GL contexts across all charts ([webgl/context-pool.ts]), so a page\n * can't sensibly mix strategies per chart. Every per-chart-type subclass\n * registered in [index.ts] reads this one value when it builds its\n * renderer, so setting it once (before the first chart renders) applies\n * to all of them.\n */\nlet BLIT_MODE: \"direct\" | \"blit\" = RENDER_BLIT_MODE;\n\nexport class HTMLPerspectiveViewerWebGLPluginElement\n extends HTMLElement\n implements IPerspectiveViewerPlugin\n{\n declare _chartType: ChartTypeConfig;\n\n private _initialized = false;\n private _glCanvas!: HTMLCanvasElement;\n private _gridlineCanvas!: HTMLCanvasElement;\n private _chromeCanvas!: HTMLCanvasElement;\n private _renderer: RendererTransport | null = null;\n private _rendererPromise: Promise<RendererTransport> | null = null;\n private _rawEventForwarder: RawEventForwarder | null = null;\n private _resetClickAbort: AbortController | null = null;\n\n /**\n * Plugin-scoped global config. Seeded lazily from\n * `_effectiveDefaults()` (which folds\n * `_chartType.plugin_field_defaults` over `DEFAULT_PLUGIN_CONFIG`)\n * because base-class field initializers run before the subclass\n * `_chartType` assignment. `restore({ plugin_config })` merges\n * incoming values on top of the same effective defaults so fields\n * the host omits fall back to the chart-type default\n * (`include_zero = true` for Y Bar / Y Area / X Bar, `false`\n * elsewhere). Held on the element (not just inside the worker) so\n * a `_buildRenderer` triggered after a `restore` ships the\n * resolved values in the `InitMsg`.\n */\n private _pluginConfigStore: PluginConfig | null = null;\n\n /**\n * Per-column config (`alt_axis`, `chart_type`, formats, \u2026), held on\n * the element for the same reason as `_pluginConfigStore`: the host\n * calls `restore()` BEFORE the first draw builds the renderer, so\n * forwarding only to a live renderer silently drops the initial\n * `columns_config` \u2014 `_buildRenderer` ships it in the `InitMsg`\n * instead.\n */\n private _columnsConfig: Record<string, any> = {};\n\n private get _pluginConfig(): PluginConfig {\n if (!this._pluginConfigStore) {\n this._pluginConfigStore = this._effectiveDefaults();\n }\n\n return this._pluginConfigStore;\n }\n\n private set _pluginConfig(value: PluginConfig) {\n this._pluginConfigStore = value;\n }\n\n private _effectiveDefaults(): PluginConfig {\n return {\n ...DEFAULT_PLUGIN_CONFIG,\n ...(this._chartType.plugin_field_defaults ?? {}),\n };\n }\n\n connectedCallback() {\n if (!this._initialized) {\n this.attachShadow({ mode: \"open\" });\n for (const sheet of GLOBAL_STYLES) {\n this.shadowRoot!.adoptedStyleSheets.push(sheet);\n }\n\n this.shadowRoot!.innerHTML =\n `<div class=\"webgl-container\">` +\n `<div class=\"zoom-controls\">` +\n `<button class=\"zoom-reset\">Reset Zoom</button>` +\n `</div>` +\n `</div>`;\n\n this._initialized = true;\n }\n\n if (!this._glCanvas?.isConnected) {\n this._buildCanvasStack();\n }\n }\n\n private _buildCanvasStack(): void {\n const container = this.shadowRoot!.querySelector(\".webgl-container\")!;\n container.insertAdjacentHTML(\n \"afterbegin\",\n `<canvas class=\"webgl-gridlines\"></canvas>` +\n `<canvas class=\"webgl-canvas\"></canvas>` +\n `<canvas class=\"webgl-chrome\"></canvas>`,\n );\n\n this._glCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-canvas\")!;\n this._gridlineCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-gridlines\")!;\n this._chromeCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-chrome\")!;\n }\n\n private _clearCanvasStack(): void {\n const container = this.shadowRoot?.querySelector(\".webgl-container\");\n if (container) {\n for (const c of Array.from(container.querySelectorAll(\"canvas\"))) {\n c.remove();\n }\n }\n\n this._glCanvas = null!;\n this._gridlineCanvas = null!;\n this._chromeCanvas = null!;\n }\n\n /**\n * Fires when the host (`<perspective-viewer>`) removes this plugin\n * from the DOM on chart-type switch \u2014 see\n * `renderer/activate.rs::remove_inactive_plugin`. Without this,\n * inactive plugin instances retain their `RendererTransport`\n * (worker + WebGL context + compiled shader programs) until the\n * entire viewer is torn down, so a user cycling all 12 chart kinds\n * holds 12 GL contexts per viewer and routinely exceeds the\n * browser's per-page context cap (~16) in workspaces.\n */\n disconnectedCallback() {\n this.delete();\n this._clearCanvasStack();\n }\n\n /**\n * Lazy renderer construction. Memoizes the in-flight `init()`\n * promise so concurrent `draw()` calls during async setup await\n * the same initialization rather than racing.\n */\n private _ensureRenderer(view: View): Promise<RendererTransport> {\n if (!this._initialized) {\n this.connectedCallback();\n }\n\n if (this._rendererPromise) {\n return this._rendererPromise;\n }\n\n // `_buildRenderer` is async \u2014 it awaits `getClient`, `getTable`,\n // and a full worker handshake \u2014 so a `disconnectedCallback`\n // (toggle / chart-type switch) frequently lands *before* this\n // `.then` runs. At that point `this._renderer` is still null,\n // so `delete()`'s `if (this._renderer)` teardown is skipped and\n // the freshly-built transport (and its WebGL context) would be\n // assigned to a detached element and leak \u2014 one context per\n // raced toggle, until the browser evicts the oldest.\n //\n // `delete()` sets `_rendererPromise = null`, so promise identity\n // is the dispose signal: if `this._rendererPromise` no longer\n // points at *this* build when it resolves, the element was\n // deleted (or a reconnect started a newer build) and we destroy\n // the orphan instead of adopting it. Promise identity is the\n // right token: a rapid draw\u2192update must NOT tear down the\n // single in-flight build it shares via this memoized promise.\n const p: Promise<RendererTransport> = this._buildRenderer(view).then(\n (r) => {\n if (this._rendererPromise !== p) {\n r.destroy();\n throw new Error(\"renderer disposed during init\");\n }\n\n this._renderer = r;\n this._setupInteraction(r);\n return r;\n },\n );\n\n // Swallow the dispose rejection so it doesn't surface as an\n // unhandled rejection; `_drawImpl` catches it and bails.\n p.catch(() => {});\n this._rendererPromise = p;\n return p;\n }\n\n /**\n * Capture raw DOM events on the GL canvas with `RawEventForwarder`\n * and post them over the control channel. The renderer dispatches\n * them through its own resolver + `applyWheel` / `applyPan` for\n * zoom/pan, and through `TooltipController` virtual dispatch for\n * hover/click; `zoomChanged` updates push back so the reset-zoom\n * button visibility tracks the renderer-side state.\n *\n * The `zoomChanged` callback was wired at `RendererTransport`\n * construction time; here we just attach the event forwarder and\n * the reset-button click handler.\n */\n private _setupInteraction(renderer: RendererTransport): void {\n if (this._rawEventForwarder) {\n return;\n }\n\n const zoomControls = this.shadowRoot!.querySelector(\n \".zoom-controls\",\n ) as HTMLDivElement | null;\n\n this._rawEventForwarder = new RawEventForwarder();\n this._rawEventForwarder.attach(this._glCanvas, (event) => {\n renderer.forwardInteraction(event);\n });\n\n const resetBtn = this.shadowRoot!.querySelector(\".zoom-reset\");\n if (resetBtn) {\n this._resetClickAbort = new AbortController();\n resetBtn.addEventListener(\n \"click\",\n () => {\n renderer.resetAllZooms();\n if (zoomControls) {\n zoomControls.classList.remove(\"visible\");\n }\n },\n { signal: this._resetClickAbort.signal },\n );\n }\n }\n\n private async _buildRenderer(view: View): Promise<RendererTransport> {\n const viewer = this.parentElement as HTMLPerspectiveViewerElement;\n // This chart's own panel (its `slot`). Used to scope the client/table\n // to THIS panel rather than the host's active/seed panel (the bare\n // getClient()/getTable() resolve element-wide in a multi-panel viewer),\n // and to tag the dispatched interaction events with their source panel.\n const panel = this.getAttribute(\"slot\") ?? undefined;\n const client = await viewer.getClient({ panel });\n const viewer_class = customElements.get(\"perspective-viewer\");\n const clientWasm = viewer_class.get_wasm_module();\n const clientWorkerURL = viewer_class.get_worker_url();\n const table = await viewer?.getTable?.({ panel });\n const tableName: string | undefined = table\n ? await table.get_name()\n : undefined;\n\n const zoomControls = this.shadowRoot!.querySelector(\n \".zoom-controls\",\n ) as HTMLDivElement | null;\n\n const transport = new RendererTransport({\n client,\n view,\n tableName,\n panel,\n clientWorkerURL,\n clientWasm,\n chartTag: this._chartType.tag,\n maxCells: this._chartType.max_cells,\n precompileShaders: true,\n onZoomChanged: (isDefault: boolean) => {\n if (zoomControls) {\n zoomControls.classList.toggle(\"visible\", !isDefault);\n }\n },\n });\n\n await transport.init({\n gl: this._glCanvas,\n gridlines: this._gridlineCanvas,\n chrome: this._chromeCanvas,\n facetConfig: {\n ...FACET_CONFIG_DEFAULTS,\n facet_mode: this._pluginConfig.facet_mode,\n zoom_mode: this._pluginConfig.facet_zoom_mode,\n },\n pluginConfig: this._pluginConfig,\n columnsConfig: this._columnsConfig,\n defaultChartType: this._chartType.default_chart_type,\n renderBlitMode: BLIT_MODE,\n });\n\n return transport;\n }\n\n /**\n * Select the GL presentation strategy for *all* chart-type plugins\n * in this renderer. Static + process-global: the value is shared by\n * every per-chart-type subclass, so it must be set once before the\n * charts that should use it build their renderers (a renderer reads\n * {@link BLIT_MODE} at construction in `_buildRenderer`; charts\n * already built keep their mode until torn down and rebuilt).\n *\n * - `\"direct\"` \u2014 each chart owns a GL context 1:1 with its visible\n * canvas (lowest latency; bounded by the browser's ~16-context\n * cap).\n * - `\"blit\"` \u2014 charts render off-screen and share a pool of GL\n * contexts ([webgl/context-pool.ts]), so a page can exceed the cap.\n */\n static setBlitMode(mode: \"direct\" | \"blit\") {\n BLIT_MODE = mode;\n }\n\n get_static_config(): PluginStaticConfig {\n return {\n name: this._chartType.name,\n category: this._chartType.category,\n select_mode: this._chartType.selectMode,\n min_config_columns: this._chartType.initial.count,\n config_column_names: this._chartType.initial.names,\n max_cells: this._chartType.max_cells,\n max_columns: this._chartType.max_columns,\n group_rollup_modes: [\"flat\"],\n split_rollup_modes: [\"flat\"],\n group_by_role: this._chartType.group_by_role,\n split_by_role: this._chartType.split_by_role,\n connects_row_order: !!this._chartType.connects_row_order,\n priority: 0,\n can_render_column_styles:\n !!this._chartType.default_chart_type ||\n this._chartType.category === \"Cartesian Charts\",\n };\n }\n\n column_config_schema(\n column_type: string,\n _group: string | undefined,\n _column_name: string,\n current_value: Record<string, unknown> | null,\n _viewer_config?: { group_by?: string[]; group_rollup_mode?: string },\n ) {\n const fields: Array<Record<string, unknown> & { kind: string }> = [];\n\n // Y-series plugins expose the per-column chart_type picker; non-Y\n // plugins leave `default_chart_type` unset.\n const def = this._chartType.default_chart_type;\n if (def && (column_type === \"integer\" || column_type === \"float\")) {\n fields.push({\n kind: \"Enum\",\n key: \"chart_type\",\n default: def,\n variants: [\n { value: \"bar\", label: \"Bar\" },\n { value: \"line\", label: \"Line\" },\n { value: \"scatter\", label: \"Scatter\" },\n { value: \"area\", label: \"Area\" },\n ],\n });\n\n const effective_chart_type =\n (current_value?.chart_type as string | undefined) ?? def;\n\n const supports_stack =\n effective_chart_type === \"bar\" ||\n effective_chart_type === \"area\";\n\n if (supports_stack) {\n fields.push({\n kind: \"Bool\",\n key: \"stack\",\n default: supports_stack,\n });\n }\n\n const is_series_glyph =\n def === \"bar\" ||\n def === \"line\" ||\n def === \"scatter\" ||\n def === \"area\";\n\n if (is_series_glyph) {\n fields.push({\n kind: \"Bool\",\n key: \"alt_axis\",\n default: false,\n });\n }\n\n // Line / area glyphs can bridge interior nulls by linear\n // interpolation. Bar / scatter ignore the flag.\n const supports_interpolate =\n effective_chart_type === \"line\" ||\n effective_chart_type === \"area\";\n\n if (supports_interpolate) {\n const variants =\n effective_chart_type === \"area\"\n ? [\n { value: \"skip\", label: \"Skip\" },\n { value: \"solid\", label: \"Solid\" },\n ]\n : [\n { value: \"skip\", label: \"Skip\" },\n { value: \"solid\", label: \"Solid\" },\n { value: \"transparent\", label: \"Transparent\" },\n ];\n fields.push({\n kind: \"Enum\",\n key: \"interpolate\",\n default: \"solid\",\n variants,\n });\n }\n }\n\n // Per-column formatter widgets. Surfaced for every chart type so\n // axes / tooltips / legends honor the user's format choice.\n if (column_type === \"integer\" || column_type === \"float\") {\n fields.push({ kind: \"NumberFormat\" });\n } else if (column_type === \"date\" || column_type === \"datetime\") {\n fields.push({ kind: \"DatetimeFormat\" });\n }\n\n return { fields };\n }\n\n plugin_config_schema(_view_config?: {\n group_by?: string[];\n group_rollup_mode?: string;\n }) {\n const defaults = this._effectiveDefaults();\n const fields = this._chartType.applicable_plugin_fields.map((key) =>\n fieldSpec(key, defaults),\n );\n\n return { fields };\n }\n\n async draw(view: View): Promise<void> {\n // `draw` always indicates a view-level change (pivots, columns,\n // filters, sorts, schema, \u2026) \u2014 invalidate the `domain_mode:\n // \"expand\"` accumulator so the new view's extent starts fresh.\n // `update` (data-only redraw on the same view) shares\n // `_drawImpl` but skips this reset.\n this._renderer?.resetExpandedDomain();\n this._renderer?.resetAllZooms();\n return this._drawImpl(view);\n }\n\n async update(view: View): Promise<void> {\n return this._drawImpl(view);\n }\n\n /**\n * Shared body of `draw` / `update`. No re-entrancy guard: the host\n * serializes every rendering call (`draw`, `update`, `render`,\n * `resize`) and `delete` on its per-renderer draw lock, so this\n * method never overlaps itself or a teardown. The one exception \u2014\n * an external DOM disconnect `delete()`ing the element mid-draw \u2014\n * is absorbed by `RendererTransport`, whose post-`destroy()`\n * requests settle immediately instead of pending forever.\n */\n private async _drawImpl(view: View): Promise<void> {\n let renderer: RendererTransport;\n try {\n renderer = await this._ensureRenderer(view);\n } catch {\n // Renderer was disposed mid-init (element disconnected\n // during the async build) \u2014 nothing to draw.\n return;\n }\n\n renderer.setView(view);\n renderer.setBufferMaxCapacity(this._chartType.max_cells);\n const panel = this.getAttribute(\"slot\") ?? undefined;\n const viewer = this\n .parentElement as HTMLPerspectiveViewerElement | null;\n\n if (viewer === null) {\n return;\n }\n\n const viewerConfig = await viewer.getViewConfig({ panel });\n await renderer.loadAndRender({\n viewerConfig: {\n group_by: viewerConfig?.group_by ?? [],\n split_by: viewerConfig?.split_by ?? [],\n columns: viewerConfig?.columns ?? [],\n },\n options: { float32: true },\n });\n }\n\n async clear(): Promise<void> {\n this._renderer?.clear();\n }\n\n async resize(): Promise<void> {\n // Hidden (an unslotted tab-stack panel, a `display: none` host):\n // the 0\u00D70 rect a hidden element reports would resize the worker\n // canvas to zero \u2014 CLEARING the retained frame, so the next\n // activation repaints from blank (the two-stage tab-switch\n // artifact). Skip instead and keep the last frame for an instant,\n // single-blit reveal \u2014 mirroring the datagrid's guard. The host's\n // activation nudge is also a `resize()`, so a hidden panel's nudge\n // is free by the same check.\n if (!this.isConnected || this.offsetParent == null) {\n return;\n }\n\n // AWAITED to the resized frame's PRESENT (the worker's\n // `resizeAck`) \u2014 the host's presize protocol style-overrides\n // this element to its target box and holds the layout commit on\n // this promise, so resolving at message-post would commit the\n // settings-pane layout against the old-dimensions bitmap (the\n // aspect-ratio warp the datagrid's synchronous resize never\n // shows).\n await this._renderer?.resize();\n }\n\n /**\n * OPTIONAL host presize protocol: render at the TARGET element box\n * `(width, height)` \u2014 the box the host's pending layout commit will\n * produce \u2014 holding the resulting frame offscreen, so nothing on\n * screen changes during the round-trip. Resolves, once the resized\n * frame is staged, to a present closure; the host calls it in the\n * same task as the layout commit, landing geometry and pixels in\n * one paint. Plugins without this method get the host's held\n * style-override presize path instead.\n */\n async presize(width: number, height: number): Promise<(() => void) | void> {\n if (\n !this.isConnected ||\n this.offsetParent == null ||\n !this._renderer ||\n !this._glCanvas\n ) {\n return;\n }\n\n // Target GL-canvas box = its current box shifted by the element's\n // box delta \u2014 the chrome between the element edge and the canvas\n // is constant across a resize.\n const hostRect = this.getBoundingClientRect();\n const glRect = this._glCanvas.getBoundingClientRect();\n return await this._renderer.presize(\n Math.max(0, glRect.width + (width - hostRect.width)),\n Math.max(0, glRect.height + (height - hostRect.height)),\n );\n }\n\n restyle() {\n this._renderer?.invalidateTheme();\n }\n\n /**\n * Clear any active selection state (pinned tooltip) WITHOUT emitting\n * selection events \u2014 the host calls this when a global filter\n * contributed by this panel's selection is removed from the global\n * filter bar, so the pin can't outlive the filter it produced. The\n * transport's `_lastInsertConfig` (remove-set memory) is deliberately\n * RETAINED so a subsequent selection still replaces any leftover\n * clauses rather than accumulating.\n */\n async deselect(): Promise<void> {\n this._renderer?.deselect();\n }\n\n async render(view: View): Promise<Blob> {\n await this._ensureRenderer(view);\n await this.draw(view);\n return this._renderer!.snapshotPng();\n }\n\n restore(config: any, columns_config?: Record<string, any>) {\n if (config?.zoom) {\n this._renderer?.restoreZoom(config.zoom);\n }\n\n // Merge incoming plugin_config on top of the `chart_type`\n // effective defaults so a partial restore (UI emits only\n // changed fields) keeps untouched defaults in place \u2014 and\n // chart-type overrides (e.g. `include_zero=true` for Y Bar /\n // Y Area / X Bar) survive when the host elides their values.\n this._pluginConfig = {\n ...this._effectiveDefaults(),\n ...config,\n };\n\n this._columnsConfig = columns_config ?? {};\n this._renderer?.setPluginConfig(this._pluginConfig);\n this._renderer?.setColumnsConfig(this._columnsConfig);\n }\n\n delete() {\n if (this._rawEventForwarder) {\n this._rawEventForwarder.detach();\n this._rawEventForwarder = null;\n }\n\n if (this._resetClickAbort) {\n this._resetClickAbort.abort();\n this._resetClickAbort = null;\n }\n\n if (this._renderer) {\n this._renderer.destroy();\n this._renderer = null;\n }\n\n this._rendererPromise = null;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport CHARTS from \"./plugin/charts\";\nimport { HTMLPerspectiveViewerWebGLPluginElement } from \"./plugin/plugin\";\n\nexport type { PerspectiveClickDetail } from \"./event-detail\";\nexport { PerspectiveSelectDetail } from \"./event-detail\";\n\nexport function register(...plugin_names: string[]) {\n const plugins = new Set(\n plugin_names.length > 0\n ? plugin_names\n : CHARTS.map((chart) => chart.name),\n );\n\n const already_registered: string[] = [];\n\n CHARTS.forEach((chart) => {\n if (plugins.has(chart.name)) {\n const tagName = `perspective-viewer-charts-${chart.tag}`;\n\n if (customElements.get(tagName)) {\n already_registered.push(tagName);\n return;\n }\n\n customElements.define(\n tagName,\n class extends HTMLPerspectiveViewerWebGLPluginElement {\n _chartType = chart;\n static _chartType = chart;\n },\n );\n\n customElements.whenDefined(\"perspective-viewer\").then(async () => {\n const Viewer = customElements.get(\"perspective-viewer\") as any;\n await Viewer.registerPlugin(tagName);\n });\n }\n });\n\n if (already_registered.length > 0) {\n console.warn(\n `viewer-charts plugins already registered (${already_registered.length}); skipping duplicate registration (Perspective was loaded more than once on this page).`,\n );\n }\n}\n\nregister();\n"],
5
- "mappings": "AAuFA,IAAMA,EAAS,gBACTC,EAAO,mBACPC,EAAO,sBACPC,EAAM,mBACNC,EAAM,aACNC,GAAS,CAAC,QAAQ,EAClBC,EAAS,CAAC,QAAQ,EAClBC,EAAS,SACTC,EAAS,SAUf,IAAMC,EAA8C,CAChD,kBACA,aACA,mBACA,eACA,cACA,gBACA,gBACA,kBACA,eACJ,EAMMC,EAAyC,CAAE,WAAY,SAAU,EAKjEC,EAAgD,CAClD,GAAGD,EACH,aAAc,EAClB,EAIME,EAAiD,CACnD,aACA,kBACA,cACA,gBACA,eACJ,EAIMC,EAA2C,CAC7C,aACA,mBACA,cACA,kBACA,gBACA,gBACA,oBACJ,EAGMC,EAA0C,CAAC,EAG3CC,GAA+C,CAAC,iBAAiB,EAOjEC,EAAgD,CAClD,aACA,kBACA,cACA,oBACA,gBACJ,EACMC,GAAmD,CACrD,GAAGD,EACH,eACJ,EACME,GAAgD,CAClD,GAAGF,EACH,eACJ,EACMG,GAAmD,CACrD,GAAGH,EACH,sBACA,qBACA,qBACA,mBACJ,EAMMI,GAA+C,CACjD,aACA,kBACA,cACA,sBACA,qBACA,qBACA,mBACJ,EAEA,SAASC,EACLC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAYe,CACf,MAAO,CACH,KAAAP,EACA,IAAAC,EACA,SAAAC,EACA,WAAAC,EACA,QAAS,CAAE,MAAAC,EAAO,MAAOC,CAAkB,EAC3C,UAAWE,GAAW,WAAa,IACnC,YAAaA,GAAW,aAAe,IACvC,yBAAAD,EACA,GAAIC,GAAW,mBACT,CAAE,mBAAoBA,EAAU,kBAAmB,EAC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M,GAAG,GAEtD,GAAI,eAAe,IAAIE,CAAO,EAAG,CAC7BD,EAAmB,KAAKC,CAAO,EAC/B,MACJ,CAEA,eAAe,OACXA,EACA,cAAcC,CAAwC,CAClD,WAAaH,EACb,OAAO,WAAaA,CACxB,CACJ,EAEA,eAAe,YAAY,oBAAoB,EAAE,KAAK,SAAY,CAE9D,MADe,eAAe,IAAI,oBAAoB,EACzC,eAAeE,CAAO,CACvC,CAAC,CACL,CACJ,CAAC,EAEGD,EAAmB,OAAS,GAC5B,QAAQ,KACJ,6CAA6CA,EAAmB,MAAM,0FAC1E,CAER,CAEAL,GAAS",
6
- "names": ["SERIES", "CART", "HIER", "FIN", "MAP", "X_AXIS", "Y_AXIS", "SELECT", "TOGGLE", "SERIES_FIELDS", "SERIES_DEFAULTS", "ZERO_ANCHORED_DEFAULTS", "CARTESIAN_FIELDS", "FIN_FIELDS", "NO_FIELDS", "HEATMAP_FIELDS", "MAP_BASE_FIELDS", "MAP_SCATTER_FIELDS", "MAP_LINE_FIELDS", "MAP_DENSITY_FIELDS", "DENSITY_FIELDS", "make", "name", "tag", "category", "selectMode", "count", "names", "applicable_plugin_fields", "overrides", "FIN_NAMES", "HIER_NAMES", "SERIES_Y_ROLES", "SERIES_X_ROLES", "CART_ROLES", "HIER_ROLES", "HEATMAP_ROLES", "FIN_ROLES", "MAP_ROLES", "CHARTS", "SERIES", "SELECT", "X_AXIS", "Y_AXIS", "CART", "TOGGLE", "HIER", "FIN", "MAP", "charts_default", "perspective_viewer_charts_default", "DEFAULT_FACET_CONFIG", "DEFAULT_PLUGIN_CONFIG", "RawEventForwarder", "element", "emit", "e", "rect", "mx", "my", "PerspectiveSelectDetail", "THEME_VARS", "snapshotThemeVars", "el", "style", "out", "v", "raw", "key", "snapshotFontFaces", "out", "sheet", "rules", "base", "rule", "style", "rawFamily", "rawSrc", "stripOuterQuotes", "resolveSrcUrls", "optional", "prop", "s", "first", "last", "src", "match", "_quote", "url", "DomHostSink", "glCanvas", "parent", "lines", "pos", "bounds", "div", "divW", "divH", "tx", "ty", "cursor", "RUNTIME_MODE", "RENDER_BLIT_MODE", "renderer_default", "cached", "getWorkerURL", "blob", "renderer_default", "renderer_worker_default", "getWorkerURL", "SHARED_WORKER", "HOST_LISTENERS", "NEXT_SESSION_ID", "getSharedWorker", "url", "renderer_worker_default", "w", "e", "env", "RendererTransport", "opts", "resolve", "reject", "workerURL", "RUNTIME_MODE", "bytes", "buf", "glOC", "gridlinesOC", "chromeOC", "rect", "dpr", "themeVars", "snapshotThemeVars", "fontFaces", "snapshotFontFaces", "clientWasm", "clientWorkerURL", "proxyPort", "initMsg", "msg", "transfer", "sessionId", "cb", "mod", "channel", "view", "cfg", "n", "id", "promise", "last", "cssWidth", "cssHeight", "err", "staged", "kind", "state", "event", "teardownErr", "entry", "removeConfigs", "insertConfigs", "detail", "PerspectiveSelectDetail", "value", "bitmap", "h", "ev", "node", "parent", "DomHostSink", "FACET_CONFIG_DEFAULTS", "DEFAULT_FACET_CONFIG", "FIELD_SCHEMAS", "fieldSpec", "key", "defaults", "GLOBAL_STYLES", "sheet", "perspective_viewer_charts_default", "BLIT_MODE", "RENDER_BLIT_MODE", "HTMLPerspectiveViewerWebGLPluginElement", "value", "DEFAULT_PLUGIN_CONFIG", "container", "c", "view", "p", "r", "renderer", "zoomControls", "RawEventForwarder", "event", "resetBtn", "viewer", "panel", "client", "viewer_class", "clientWasm", "clientWorkerURL", "table", "tableName", "transport", "RendererTransport", "isDefault", "mode", "column_type", "_group", "_column_name", "current_value", "_viewer_config", "fields", "def", "effective_chart_type", "supports_stack", "variants", "_view_config", "viewerConfig", "width", "height", "hostRect", "glRect", "config", "columns_config", "register", "plugin_names", "plugins", "charts_default", "chart", "already_registered", "tagName", "HTMLPerspectiveViewerWebGLPluginElement"]
3
+ "sources": ["../../src/ts/plugin/charts.ts", "../../src/ts/utils/css.ts", "../../src/ts/theme/gradient.ts", "../../src/css/perspective-viewer-charts.css", "../../src/ts/map/tile-sources.json", "../../src/ts/map/tile-source.ts", "../../src/ts/charts/chart.ts", "../../src/ts/plugin/format-defaults.ts", "../../src/ts/interaction/raw-event-forwarder.ts", "../../src/ts/event-detail.ts", "../../src/ts/theme/theme-snapshot.ts", "../../src/ts/utils/font-snapshot.ts", "../../src/ts/interaction/tooltip-grid.ts", "../../src/ts/interaction/host-sink-dom.ts", "../../src/ts/config.ts", "worker:../worker/renderer.js", "worker-stub:../worker/renderer.worker.js", "../../src/ts/transport/renderer-transport.ts", "../../src/ts/theme/theme.ts", "../../src/ts/theme/palette.ts", "../../src/ts/plugin/plugin.ts", "../../src/ts/index.ts"],
4
+ "sourcesContent": ["// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { PluginConfig } from \"../charts/chart\";\n\nexport type ChartType = \"bar\" | \"line\" | \"scatter\" | \"area\";\n\nexport type PluginChartType = ChartType | \"candlestick\" | \"ohlc\";\n\n/**\n * Subset of `PluginConfig` keys that a chart impl actually consumes.\n * Drives `plugin_config_schema()` filtering \u2014 the host only renders\n * the controls listed here, and `plugin.restore({ plugin_config })`\n * still hands the full struct to the worker (other keys are inert).\n */\nexport type PluginConfigField = keyof PluginConfig;\n\nexport interface ChartTypeConfig {\n name: string;\n tag: string;\n category: string;\n selectMode: \"select\" | \"toggle\";\n initial: {\n count: number;\n names: string[];\n };\n max_cells: number;\n max_columns: number;\n default_chart_type?: PluginChartType;\n\n /**\n * Plugin-config keys this chart type renders controls for. Empty\n * for plugins with no global settings (heatmap / treemap /\n * sunburst). See {@link PluginConfig} for field semantics.\n */\n applicable_plugin_fields: readonly PluginConfigField[];\n\n /**\n * What `group_by` DRAWS in this chart, e.g. `\"X Axis\"` for the\n * Y-series charts. Omitted where the field has no visual role of\n * its own and is a plain aggregation key \u2014 the X/Y and map charts,\n * whose axes both come from `columns`.\n *\n * The `group_by` counterpart of `initial.names`: one declaration\n * says what every view field draws, so the settings UI's labels and\n * the agent's `list_plugins` contract read the same source instead\n * of restating the mapping.\n */\n group_by_role?: string;\n\n /** What `split_by` DRAWS in this chart. See {@link group_by_role}. */\n split_by_role?: string;\n\n /**\n * Set on the charts that CONNECT their points in row order, so the\n * view's row order shows up in the drawing: without a `sort` the\n * line follows the table's natural order, which reads as a tangle\n * unless the rows already arrive ordered along the X axis. The point\n * charts (scatter, density) are unaffected, and a pre-ordered table\n * needs no `sort` \u2014 which is why this is declared per chart rather\n * than inferred from an empty `sort`.\n */\n connects_row_order?: boolean;\n\n /**\n * Per-chart-type overrides for `DEFAULT_PLUGIN_CONFIG`. Used when a\n * field's sensible default differs by chart family \u2014 currently\n * `include_zero` (true for Y Bar / Y Area / X Bar, false for line\n * / scatter / cartesian / financial) and `facet_mode` (\"overlay\"\n * for the band-pipeline families \u2014 series / financial \u2014 whose\n * historical split_by rendering is the single stacked/colored\n * plot; \"grid\" elsewhere). Applied at schema generation and at\n * `restore({})` so the effective default matches the surfaced UI\n * default.\n */\n plugin_field_defaults?: Partial<PluginConfig>;\n}\n\nconst SERIES = \"Series Charts\";\nconst CART = \"Cartesian Charts\";\nconst HIER = \"Hierarchical Charts\";\nconst FIN = \"Financial Charts\";\nconst MAP = \"Map Charts\";\nconst X_AXIS = [\"X Axis\"];\nconst Y_AXIS = [\"Y Axis\"];\nconst SELECT = \"select\";\nconst TOGGLE = \"toggle\";\n\nconst DEFAULT_MAX_CELLS = 10_000_000;\nconst DEFAULT_MAX_COLUMNS = 10_000;\n\n// Plugin-config field sets, by chart family.\n//\nexport const LEGEND_FIELDS: readonly PluginConfigField[] = [\n \"legend_mode\",\n \"legend_size_mode\",\n \"legend_width_px\",\n \"legend_height_px\",\n \"legend_anchor\",\n \"legend_x\",\n \"legend_y\",\n \"legend_opacity\",\n];\n\nexport const TOOLTIP_FIELDS: readonly PluginConfigField[] = [\n \"tooltip_max_column_px\",\n \"tooltip_opacity\",\n];\n\n// Series charts paint bars / lines / scatter / area glyphs (selected\n// per-column via `chart_type`), so the union covers every glyph that\n// might appear. `auto_alt_y_axis` + `series_zoom_mode` are Series-only.\nconst SERIES_FIELDS: readonly PluginConfigField[] = [\n \"auto_alt_y_axis\",\n \"facet_mode\",\n \"series_zoom_mode\",\n \"include_zero\",\n \"domain_mode\",\n \"line_width_px\",\n \"point_size_px\",\n \"band_inner_frac\",\n \"bar_inner_pad\",\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\n\n// The band pipeline's historical split_by rendering is a single plot\n// (splits stacked / colored in place), so the series family defaults\n// `facet_mode` to \"overlay\" \u2014 grid faceting is the opt-in. Cartesian\n// charts keep the global \"grid\" default from `DEFAULT_PLUGIN_CONFIG`.\nconst SERIES_DEFAULTS: Partial<PluginConfig> = { facet_mode: \"overlay\" };\n\n// Bar / area series glyphs grow from the zero baseline, so the value\n// axis must enclose 0 to render correctly. Line / scatter glyphs have\n// no such constraint \u2014 their default `include_zero` stays `false`.\nconst ZERO_ANCHORED_DEFAULTS: Partial<PluginConfig> = {\n ...SERIES_DEFAULTS,\n include_zero: true,\n};\n\n// Pure Cartesian (X/Y Scatter, X/Y Line) \u2014 no categorical axis, so no\n// band geometry; gets the facet-routing variant of zoom_mode.\nconst CARTESIAN_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"line_width_px\",\n \"point_size_px\",\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\n\n// Candlestick/OHLC share the categorical-X build pipeline (band slots)\n// and add their two stroke widths.\nconst FIN_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"series_zoom_mode\",\n \"domain_mode\",\n \"band_inner_frac\",\n \"bar_inner_pad\",\n \"wick_width_px\",\n \"ohlc_line_width_px\",\n ...TOOLTIP_FIELDS,\n];\n\nconst TREE_FIELDS: readonly PluginConfigField[] = [\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\n\n// Heatmap\nconst HEATMAP_FIELDS: readonly PluginConfigField[] = [\n \"facet_zoom_mode\",\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\n\n// Map \u2014 reuses the cartesian build pipeline with a Mercator\n// projection hook. Carries the basemap controls (`map_tile_provider`,\n// `map_tile_alpha`) plus the relevant glyph-styling fields the\n// underlying chart type already uses. Density-on-map adds the four\n// gradient knobs on top.\nconst MAP_BASE_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"map_tile_provider\",\n \"map_tile_alpha\",\n \"numeric_axes\",\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\nconst MAP_SCATTER_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"point_size_px\",\n];\nconst MAP_LINE_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"line_width_px\",\n];\nconst MAP_DENSITY_FIELDS: readonly PluginConfigField[] = [\n ...MAP_BASE_FIELDS,\n \"gradient_color_mode\",\n \"gradient_radius_px\",\n \"gradient_intensity\",\n \"gradient_heat_max\",\n];\n\n// Density \u2014 shares the cartesian build pipeline (X/Y numeric\n// with an optional Color column), then routes through the density-field\n// glyph. Reuses the cartesian facet/zoom controls and adds the three\n// shader-specific knobs.\nconst DENSITY_FIELDS: readonly PluginConfigField[] = [\n \"facet_mode\",\n \"facet_zoom_mode\",\n \"domain_mode\",\n \"gradient_color_mode\",\n \"gradient_radius_px\",\n \"gradient_intensity\",\n \"gradient_heat_max\",\n ...LEGEND_FIELDS,\n ...TOOLTIP_FIELDS,\n];\n\nfunction make(\n name: string,\n tag: string,\n category: string,\n selectMode: \"select\" | \"toggle\",\n count: number,\n names: readonly string[],\n applicable_plugin_fields: readonly PluginConfigField[],\n overrides?: Partial<\n Pick<\n ChartTypeConfig,\n | \"max_cells\"\n | \"max_columns\"\n | \"default_chart_type\"\n | \"plugin_field_defaults\"\n | \"group_by_role\"\n | \"split_by_role\"\n | \"connects_row_order\"\n >\n >,\n): ChartTypeConfig {\n return {\n name,\n tag,\n category,\n selectMode,\n initial: { count, names: names as string[] },\n max_cells: overrides?.max_cells ?? DEFAULT_MAX_CELLS,\n max_columns: overrides?.max_columns ?? DEFAULT_MAX_COLUMNS,\n applicable_plugin_fields,\n ...(overrides?.default_chart_type\n ? { default_chart_type: overrides.default_chart_type }\n : {}),\n ...(overrides?.plugin_field_defaults\n ? { plugin_field_defaults: overrides.plugin_field_defaults }\n : {}),\n ...(overrides?.group_by_role\n ? { group_by_role: overrides.group_by_role }\n : {}),\n ...(overrides?.split_by_role\n ? { split_by_role: overrides.split_by_role }\n : {}),\n ...(overrides?.connects_row_order\n ? { connects_row_order: overrides.connects_row_order }\n : {}),\n };\n}\n\nconst FIN_NAMES = [\"Open\", \"Close\", \"High\", \"Low\", \"Tooltip\"];\nconst HIER_NAMES = [\"Size\", \"Color\", \"Tooltip\"];\n\nconst SERIES_Y_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Series\" };\nconst SERIES_X_ROLES = { group_by_role: \"Y Axis\", split_by_role: \"Series\" };\nconst CART_ROLES = {};\nconst HIER_ROLES = { group_by_role: \"Hierarchy\", split_by_role: \"Facets\" };\nconst HEATMAP_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Y Axis\" };\nconst FIN_ROLES = { group_by_role: \"X Axis\", split_by_role: \"Series\" };\nconst MAP_ROLES = {};\n\nconst CHARTS: ChartTypeConfig[] = [\n make(\"X Bar\", \"x-bar\", SERIES, SELECT, 1, X_AXIS, SERIES_FIELDS, {\n ...SERIES_X_ROLES,\n default_chart_type: \"bar\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\"Y Bar\", \"y-bar\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"bar\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\"Y Line\", \"y-line\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"line\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"Y Scatter\", \"y-scatter\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"scatter\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"Y Area\", \"y-area\", SERIES, SELECT, 1, Y_AXIS, SERIES_FIELDS, {\n ...SERIES_Y_ROLES,\n default_chart_type: \"area\",\n plugin_field_defaults: ZERO_ANCHORED_DEFAULTS,\n }),\n make(\n \"X/Y Scatter\",\n \"scatter\",\n CART,\n TOGGLE,\n 2,\n [\"X Axis\", \"Y Axis\", \"Color\", \"Size\", \"Label\", \"Tooltip\"],\n CARTESIAN_FIELDS,\n { ...CART_ROLES },\n ),\n make(\n \"X/Y Line\",\n \"line\",\n CART,\n SELECT,\n 2,\n [\"X Axis\", \"Y Axis\", \"Tooltip\"],\n CARTESIAN_FIELDS,\n { ...CART_ROLES, connects_row_order: true },\n ),\n make(\n \"Density\",\n \"density\",\n CART,\n TOGGLE,\n 2,\n [\"X Axis\", \"Y Axis\", \"Color\", \"Tooltip\"],\n DENSITY_FIELDS,\n { ...CART_ROLES },\n ),\n make(\"Treemap\", \"treemap\", HIER, TOGGLE, 1, HIER_NAMES, TREE_FIELDS, {\n ...HIER_ROLES,\n plugin_field_defaults: { legend_mode: \"sidebar\" },\n }),\n make(\"Sunburst\", \"sunburst\", HIER, TOGGLE, 1, HIER_NAMES, TREE_FIELDS, {\n ...HIER_ROLES,\n }),\n make(\"Heatmap\", \"heatmap\", HIER, SELECT, 1, [\"Color\"], HEATMAP_FIELDS, {\n ...HEATMAP_ROLES,\n plugin_field_defaults: { legend_mode: \"sidebar\" },\n }),\n make(\"Candlestick\", \"candlestick\", FIN, TOGGLE, 1, FIN_NAMES, FIN_FIELDS, {\n ...FIN_ROLES,\n default_chart_type: \"candlestick\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\"OHLC\", \"ohlc\", FIN, TOGGLE, 1, FIN_NAMES, FIN_FIELDS, {\n ...FIN_ROLES,\n default_chart_type: \"ohlc\",\n plugin_field_defaults: SERIES_DEFAULTS,\n }),\n make(\n \"Map Scatter\",\n \"map-scatter\",\n MAP,\n TOGGLE,\n 2,\n [\"Longitude\", \"Latitude\", \"Color\", \"Size\", \"Label\", \"Tooltip\"],\n MAP_SCATTER_FIELDS,\n { ...MAP_ROLES },\n ),\n make(\n \"Map Line\",\n \"map-line\",\n MAP,\n SELECT,\n 2,\n [\"Longitude\", \"Latitude\", \"Tooltip\"],\n MAP_LINE_FIELDS,\n { ...MAP_ROLES, connects_row_order: true },\n ),\n make(\n \"Map Density\",\n \"map-density\",\n MAP,\n TOGGLE,\n 2,\n [\"Longitude\", \"Latitude\", \"Color\", \"Tooltip\"],\n MAP_DENSITY_FIELDS,\n { ...MAP_ROLES },\n ),\n];\n\nexport default CHARTS;\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nexport function parseCSSColorToVec3(\n colorStr: string,\n): [number, number, number] {\n const s = colorStr.trim();\n if (s.startsWith(\"#\")) {\n let hex = s.slice(1);\n if (hex.length === 3) {\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\n }\n\n return [\n parseInt(hex.slice(0, 2), 16) / 255,\n parseInt(hex.slice(2, 4), 16) / 255,\n parseInt(hex.slice(4, 6), 16) / 255,\n ];\n }\n\n const m = s.match(/rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)/);\n if (m) {\n return [+m[1] / 255, +m[2] / 255, +m[3] / 255];\n }\n\n return [0.5, 0.5, 0.5];\n}\n\n/**\n * Format a `[0, 1]`-range RGB triple as a plain `#rrggbb` string.\n */\nexport function vec3ToHexColor(c: [number, number, number]): string {\n const channel = (x: number) =>\n Math.round(Math.max(0, Math.min(1, x)) * 255)\n .toString(16)\n .padStart(2, \"0\");\n\n return `#${channel(c[0])}${channel(c[1])}${channel(c[2])}`;\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { parseCSSColorToVec3, vec3ToHexColor } from \"../utils/css\";\n\n/**\n * A single stop on a parsed CSS gradient. `offset` \u2208 [0, 1].\n */\nexport interface GradientStop {\n offset: number;\n color: [number, number, number, number]; // RGBA, each \u2208 [0, 1]\n}\n\nconst DEFAULT_STOPS: GradientStop[] = [\n { offset: 0, color: [0x03 / 255, 0x66 / 255, 0xd6 / 255, 1] },\n { offset: 1, color: [0xff / 255, 0x7f / 255, 0x0e / 255, 1] },\n];\n\n/**\n * Parse a `linear-gradient(...)` CSS expression into ordered stops. Tolerates\n * missing percentages (distributes linearly between known offsets, matching\n * the CSS standard) and leading direction tokens (`to right`, `90deg`, etc.)\n * which are simply skipped.\n *\n * Returns the default blue \u2192 orange two-stop on any parse failure so themes\n * that never set the gradient still produce sane output.\n */\nexport function parseCssGradient(\n src: string | null | undefined,\n): GradientStop[] {\n if (!src) {\n return DEFAULT_STOPS.slice();\n }\n\n const trimmed = src.trim();\n if (!trimmed) {\n return DEFAULT_STOPS.slice();\n }\n\n // Strip the `linear-gradient(` wrapper. Bail out if we don't find it.\n const openIdx = trimmed.indexOf(\"(\");\n if (openIdx < 0) {\n return DEFAULT_STOPS.slice();\n }\n\n if (!/^linear-gradient\\s*\\(/i.test(trimmed)) {\n return DEFAULT_STOPS.slice();\n }\n\n const closeIdx = trimmed.lastIndexOf(\")\");\n if (closeIdx <= openIdx) {\n return DEFAULT_STOPS.slice();\n }\n\n const body = trimmed.substring(openIdx + 1, closeIdx);\n\n // Split on commas at depth 0 (respecting nested `rgb(...)` / `rgba(...)` /\n // `hsl(...)` parens which also contain commas).\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i++) {\n const ch = body[i];\n if (ch === \"(\") {\n depth++;\n } else if (ch === \")\") {\n depth--;\n } else if (ch === \",\" && depth === 0) {\n parts.push(body.substring(start, i));\n start = i + 1;\n }\n }\n\n parts.push(body.substring(start));\n\n // First part may be a direction (`to right`, `90deg`, `to bottom right`)\n // rather than a color-stop. Detect by: no matching color syntax.\n const stops: Array<{\n color: [number, number, number];\n offset: number | null;\n }> = [];\n let startIdx = 0;\n if (parts.length > 0) {\n const firstNorm = parts[0].trim().toLowerCase();\n if (\n firstNorm.startsWith(\"to \") ||\n /^[-\\d.]+(deg|rad|grad|turn)/.test(firstNorm)\n ) {\n startIdx = 1;\n }\n }\n\n for (let i = startIdx; i < parts.length; i++) {\n const piece = parts[i].trim();\n if (!piece) {\n continue;\n }\n\n // Peel off an optional trailing `<number>%` or `<number>px`.\n const pctMatch = piece.match(/\\s([\\-\\d.]+)%\\s*$/);\n const color = pctMatch\n ? piece.substring(0, pctMatch.index).trim()\n : piece;\n const offset = pctMatch ? parseFloat(pctMatch[1]) / 100 : null;\n try {\n const rgb = parseCSSColorToVec3(color);\n stops.push({ color: rgb, offset });\n } catch {\n // skip unparseable stop\n }\n }\n\n if (stops.length === 0) {\n return DEFAULT_STOPS.slice();\n }\n\n if (stops.length === 1) {\n // Single stop \u2192 solid color. Duplicate across [0, 1] so sampling works.\n const [r, g, b] = stops[0].color;\n return [\n { offset: 0, color: [r, g, b, 1] },\n { offset: 1, color: [r, g, b, 1] },\n ];\n }\n\n // Fill in missing offsets by linear interpolation of neighbours with\n // known positions (CSS implicit-position semantics).\n if (stops[0].offset === null) {\n stops[0].offset = 0;\n }\n\n if (stops[stops.length - 1].offset === null) {\n stops[stops.length - 1].offset = 1;\n }\n\n for (let i = 1; i < stops.length - 1; i++) {\n if (stops[i].offset !== null) {\n continue;\n }\n\n // Find next known offset.\n let j = i + 1;\n while (j < stops.length && stops[j].offset === null) {\n j++;\n }\n\n const before = stops[i - 1].offset!;\n const after = stops[j].offset!;\n const span = j - (i - 1);\n for (let k = i; k < j; k++) {\n stops[k].offset =\n before + ((k - (i - 1)) / span) * (after - before);\n }\n\n i = j - 1;\n }\n\n // Clamp offsets to [0, 1] and ensure non-decreasing order.\n let prev = 0;\n const result: GradientStop[] = stops.map((s) => {\n const off = Math.max(prev, Math.min(1, s.offset!));\n prev = off;\n return {\n offset: off,\n color: [s.color[0], s.color[1], s.color[2], 1],\n };\n });\n\n return result;\n}\n\n/**\n * A color literal \u2014 `#rgb`, `#rgba`, `#rrggbb`, `#rrggbbaa`, `rgb()` or\n * `rgba()` \u2014 as a `[0, 1]` RGB triple, or `null` for anything else.\n */\nexport function parseCssColorStrict(\n src: string,\n): [number, number, number] | null {\n const s = src.trim();\n if (s.startsWith(\"#\")) {\n const hex = s.slice(1);\n if (!/^[0-9a-f]+$/i.test(hex)) {\n return null;\n }\n\n if (hex.length === 3 || hex.length === 4) {\n return [\n parseInt(hex[0] + hex[0], 16) / 255,\n parseInt(hex[1] + hex[1], 16) / 255,\n parseInt(hex[2] + hex[2], 16) / 255,\n ];\n }\n\n if (hex.length === 6 || hex.length === 8) {\n return [\n parseInt(hex.slice(0, 2), 16) / 255,\n parseInt(hex.slice(2, 4), 16) / 255,\n parseInt(hex.slice(4, 6), 16) / 255,\n ];\n }\n\n return null;\n }\n\n const m = s.match(/^rgba?\\(([^)]*)\\)$/i);\n if (!m) {\n return null;\n }\n\n const tokens = m[1]\n .split(\"/\")[0]\n .split(/[\\s,]+/)\n .filter((x) => x.length > 0);\n if (tokens.length < 3 || tokens.length > 4) {\n return null;\n }\n\n const channel = (token: string): number | null => {\n const pct = token.endsWith(\"%\");\n const n = parseFloat(pct ? token.slice(0, -1) : token);\n if (!isFinite(n)) {\n return null;\n }\n\n const v = pct ? (n / 100) * 255 : n;\n return Math.max(0, Math.min(255, Math.round(v))) / 255;\n };\n\n const r = channel(tokens[0]);\n const g = channel(tokens[1]);\n const b = channel(tokens[2]);\n return r === null || g === null || b === null ? null : [r, g, b];\n}\n\n/**\n * The shared `linear-gradient(...)` tokenizer of the viewer's CSS-valued\n * config grammar.\n */\nexport function tokenizeLinearGradient(\n src: string,\n): Array<[[number, number, number], number | null]> | null {\n const m = src.trim().match(/^linear-gradient\\s*\\((.*)\\)$/is);\n if (!m) {\n return null;\n }\n\n const body = m[1];\n const parts: string[] = [];\n let depth = 0;\n let start = 0;\n for (let i = 0; i < body.length; i++) {\n const ch = body[i];\n if (ch === \"(\") {\n depth++;\n } else if (ch === \")\") {\n depth--;\n } else if (ch === \",\" && depth === 0) {\n parts.push(body.substring(start, i));\n start = i + 1;\n }\n }\n\n parts.push(body.substring(start));\n const out: Array<[[number, number, number], number | null]> = [];\n for (let i = 0; i < parts.length; i++) {\n const piece = parts[i].trim();\n if (!piece) {\n return null;\n }\n\n const lower = piece.toLowerCase();\n if (\n i === 0 &&\n (lower.startsWith(\"to \") ||\n /^[-\\d.]+(deg|rad|grad|turn)$/.test(lower))\n ) {\n continue;\n }\n\n const posMatch = piece.match(/\\s([^\\s)]+)$/);\n let color = piece;\n let offset: number | null = null;\n if (posMatch) {\n const tail = posMatch[1];\n if (tail.endsWith(\"%\")) {\n const n = parseFloat(tail.slice(0, -1));\n if (!isFinite(n)) {\n return null;\n }\n\n color = piece.substring(0, posMatch.index).trim();\n offset = n / 100;\n } else if (/^[-\\d.]/.test(tail)) {\n return null;\n }\n }\n\n const rgb = parseCssColorStrict(color);\n if (!rgb) {\n return null;\n }\n\n out.push([rgb, offset]);\n }\n\n return out;\n}\n\n/**\n * Strict gradient reader: a `linear-gradient(...)` with \u2265 2 stops,\n * positions optional, offsets clamped to `[0, 1]` and sorted, or `null`\n * on malformed input.\n */\nexport function parseCssGradientStrict(src: string): GradientStop[] | null {\n const entries = tokenizeLinearGradient(src);\n if (!entries || entries.length < 2) {\n return null;\n }\n\n const offsets: Array<number | null> = entries.map(([, p]) => p);\n const last = offsets.length - 1;\n if (offsets[0] === null) {\n offsets[0] = 0;\n }\n\n if (offsets[last] === null) {\n offsets[last] = 1;\n }\n\n for (let i = 1; i < last; i++) {\n if (offsets[i] !== null) {\n continue;\n }\n\n let j = i + 1;\n while (offsets[j] === null) {\n j++;\n }\n\n const before = offsets[i - 1]!;\n const after = offsets[j]!;\n const span = j - (i - 1);\n for (let k = i; k < j; k++) {\n offsets[k] = before + ((k - (i - 1)) / span) * (after - before);\n }\n\n i = j - 1;\n }\n\n const stops: GradientStop[] = entries.map(([rgb], i) => ({\n offset: Math.max(0, Math.min(1, offsets[i]!)),\n color: [rgb[0], rgb[1], rgb[2], 1],\n }));\n\n stops.sort((a, b) => a.offset - b.offset);\n return stops;\n}\n\n/**\n * Strict palette reader: a `linear-gradient(...)` of \u2265 1 colors with no\n * positions, or `null` on malformed input.\n */\nexport function parseCssColorList(\n src: string,\n): Array<[number, number, number]> | null {\n const entries = tokenizeLinearGradient(src);\n if (!entries || entries.length === 0) {\n return null;\n }\n\n const out: Array<[number, number, number]> = [];\n for (const [rgb, offset] of entries) {\n if (offset !== null) {\n return null;\n }\n\n out.push(rgb);\n }\n\n return out;\n}\n\nfunction formatPercent(offset: number): string {\n const rounded = Math.round(Math.max(0, Math.min(1, offset)) * 1000) / 10;\n return `${rounded}%`;\n}\n\n/**\n * The viewer's canonical gradient string for `stops`: `linear-gradient(to\n * right, #rrggbb P%, \u2026)`, sorted, positions at 0.1% resolution.\n */\nexport function stopsToCss(stops: GradientStop[]): string {\n const body = [...stops]\n .sort((a, b) => a.offset - b.offset)\n .map(\n (stop) =>\n `${vec3ToHexColor([stop.color[0], stop.color[1], stop.color[2]])} ${formatPercent(stop.offset)}`,\n )\n .join(\", \");\n\n return `linear-gradient(to right, ${body})`;\n}\n\n/**\n * The viewer's canonical palette string for `colors`: the same frame\n * with bare `#rrggbb` entries and no positions.\n */\nexport function colorsToCss(colors: Array<[number, number, number]>): string {\n return `linear-gradient(to right, ${colors.map(vec3ToHexColor).join(\", \")})`;\n}\n\n/**\n * Piecewise-linear color sample at `t \u2208 [0, 1]`. Returns RGBA in [0, 1].\n * Clamps `t` to the gradient's first/last stop outside `[0, 1]`.\n */\nexport function sampleGradient(\n stops: GradientStop[],\n t: number,\n): [number, number, number, number] {\n if (stops.length === 0) {\n return [0, 0, 0, 1];\n }\n\n if (t <= stops[0].offset) {\n return stops[0].color.slice() as [number, number, number, number];\n }\n\n const last = stops[stops.length - 1];\n if (t >= last.offset) {\n return last.color.slice() as [number, number, number, number];\n }\n\n // Bisect for the interval containing `t`.\n let lo = 0;\n let hi = stops.length - 1;\n while (hi - lo > 1) {\n const mid = (lo + hi) >> 1;\n if (stops[mid].offset <= t) {\n lo = mid;\n } else {\n hi = mid;\n }\n }\n\n const a = stops[lo];\n const b = stops[hi];\n const span = b.offset - a.offset;\n const u = span > 0 ? (t - a.offset) / span : 0;\n return [\n a.color[0] + (b.color[0] - a.color[0]) * u,\n a.color[1] + (b.color[1] - a.color[1]) * u,\n a.color[2] + (b.color[2] - a.color[2]) * u,\n a.color[3] + (b.color[3] - a.color[3]) * u,\n ];\n}\n\n/**\n * Sign-aware normalization. Returns `t \u2208 [0, 1]` where the 50% stop is\n * always the sign pivot:\n * - crosses zero \u2192 `[-maxAbs, maxAbs]` stretched symmetrically; 0 \u2192 0.5.\n * - all-positive \u2192 `[0, colorMax]` occupies top half `[0.5, 1]`.\n * - all-negative \u2192 `[colorMin, 0]` occupies bottom half `[0, 0.5]`.\n * - degenerate \u2192 0.5 (single colour at the midpoint).\n */\nexport function colorValueToT(\n value: number,\n colorMin: number,\n colorMax: number,\n): number {\n if (!isFinite(value) || colorMin === colorMax) {\n return 0.5;\n }\n\n let denom: number;\n if (colorMin >= 0) {\n denom = colorMax;\n } else if (colorMax <= 0) {\n denom = -colorMin;\n } else {\n denom = Math.max(-colorMin, colorMax);\n }\n\n if (denom <= 0) {\n return 0.5;\n }\n\n const t = 0.5 + 0.5 * (value / denom);\n return t < 0 ? 0 : t > 1 ? 1 : t;\n}\n\nexport function colorRangePivot(\n colorMin: number,\n colorMax: number,\n): [number, number] {\n if (!isFinite(colorMin) || !isFinite(colorMax) || colorMin >= colorMax) {\n return [0, 0];\n }\n\n let denom: number;\n if (colorMin >= 0) {\n denom = colorMax;\n } else if (colorMax <= 0) {\n denom = -colorMin;\n } else {\n denom = Math.max(-colorMin, colorMax);\n }\n\n if (denom <= 0) {\n return [0, 0];\n }\n\n return [-denom, denom];\n}\n\n/**\n * Convert a discrete series palette (from `--psp-charts--series-N--color`)\n * into a `GradientStop[]` with stops at `i / (N - 1)`. The resulting\n * stops can feed `buildGradientLUT` / `ensureGradientTexture` / any\n * other code path that already accepts a gradient \u2014 so categorical\n * coloring and numeric gradients share one LUT pipeline. Integer idx\n * sampling via `t = idx / (N - 1)` lands exactly on a palette color;\n * the linear blend between stops is only hit by non-integer samples\n * (which categorical data doesn't produce).\n */\nexport function paletteToStops(\n palette: [number, number, number][],\n): GradientStop[] {\n if (palette.length === 0) {\n return DEFAULT_STOPS.slice();\n }\n\n if (palette.length === 1) {\n const [r, g, b] = palette[0];\n return [\n { offset: 0, color: [r, g, b, 1] },\n { offset: 1, color: [r, g, b, 1] },\n ];\n }\n\n const denom = palette.length - 1;\n return palette.map(([r, g, b], i) => ({\n offset: i / denom,\n color: [r, g, b, 1],\n }));\n}\n\n/**\n * Bake a sampled LUT for GPU upload as RGBA8 (`size \u00D7 1`). Default 256\n * samples \u2014 visually indistinguishable from a denser sample at typical\n * viewport sizes and keeps the texture tiny (1 KB).\n */\nexport function buildGradientLUT(\n stops: GradientStop[],\n size: number = 256,\n): Uint8Array {\n const out = new Uint8Array(size * 4);\n for (let i = 0; i < size; i++) {\n const t = size === 1 ? 0 : i / (size - 1);\n const c = sampleGradient(stops, t);\n out[i * 4] = Math.round(c[0] * 255);\n out[i * 4 + 1] = Math.round(c[1] * 255);\n out[i * 4 + 2] = Math.round(c[2] * 255);\n out[i * 4 + 3] = Math.round(c[3] * 255);\n }\n\n return out;\n}\n", ":host{--psp-charts--tooltip--color:var(--psp--color);--psp-charts--tooltip--background:var(--psp--background-color);--psp-charts--tooltip--border-color:var(--psp-inactive--border-color);width:100%;height:100%;font-family:inherit;display:block;position:relative;overflow:hidden}.webgl-container{position:absolute;inset:6px}.webgl-canvas{width:100%;height:100%;position:absolute;top:0;left:0}.webgl-gridlines,.webgl-chrome{pointer-events:none;width:100%;height:100%;position:absolute;top:0;left:0}.zoom-controls{z-index:2;pointer-events:auto;display:none;position:absolute;top:8px;left:50%;transform:translate(-50%)}.zoom-controls.visible{gap:6px;display:flex}.zoom-reset{background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);font:11px var(--psp-charts--font-family);cursor:pointer;opacity:.7;border-radius:4px;padding:4px 12px;transition:opacity .15s}.zoom-reset:hover{opacity:1}.webgl-tooltip{pointer-events:auto;font:11px var(--psp-charts--font-family);background:var(--psp-charts--tooltip--background);color:var(--psp-charts--tooltip--color);border:1px solid var(--psp-charts--tooltip--border-color);z-index:10;border-radius:3px;padding:3px;line-height:16px;position:absolute;overflow-y:auto}", "[\n {\n \"id\": \"osm\",\n \"label\": \"OpenStreetMap\",\n \"template\": \"https://tile.openstreetmap.org/{z}/{x}/{y}.png\",\n \"attribution\": \"\u00A9 OpenStreetMap contributors\",\n \"tile_size\": 256,\n \"max_zoom\": 19\n },\n {\n \"id\": \"versatiles-satellite\",\n \"label\": \"Satellite (VersaTiles)\",\n \"template\": \"https://tiles.versatiles.org/tiles/satellite/{z}/{x}/{y}\",\n \"attribution\": \"\u00A9 VersaTiles (versatiles.org/sources)\",\n \"tile_size\": 256,\n \"max_zoom\": 12\n }\n]\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport TILE_SOURCE_SEED from \"./tile-sources.json\";\n\n/**\n * A tile source describes *where* to fetch raster XYZ tiles and what\n * attribution text the renderer must display in the chrome canvas.\n * Implementations are stateless \u2014 the tile loader handles caching and\n * in-flight dedup.\n */\nexport interface TileSource {\n /**\n * Build the URL for tile (z, x, y). Implementations typically\n * substitute a template like `{z}/{x}/{y}` and may rotate\n * subdomains for browsers that throttle concurrent connections\n * per host.\n */\n urlFor(z: number, x: number, y: number): string;\n\n /**\n * Plain-text attribution shown in the bottom-right of the chrome\n * canvas. Required by every major tile provider's terms of use \u2014\n * do not suppress it without provider-side opt-out.\n */\n readonly attribution: string;\n\n /**\n * Side length of one tile in pixels. Tile providers ship 256 by\n * default; a few offer 512 (`@2x`) variants. Used by the zoom-\n * level picker to convert meters-per-pixel into a zoom level.\n */\n readonly tileSize: number;\n\n /**\n * Maximum zoom level the provider serves. Tiles requested above\n * this fall back to the deepest available level with sub-tile\n * UVs \u2014 same trick used during async loads.\n */\n readonly maxZoom: number;\n\n /**\n * Stable identifier for caching. Two `TileSource` instances with\n * the same `id` share a tile cache; switching source (e.g. theme\n * change) invalidates and re-fetches.\n */\n readonly id: string;\n}\n\n/**\n * Subdomain-rotated URL template. Replaces `{s}` with one of the\n * provided subdomains hashed by `(x + y)`, and `{z}`, `{x}`, `{y}`\n * with the tile address. Most major tile providers fit this shape.\n */\nexport class TemplatedTileSource implements TileSource {\n constructor(\n readonly id: string,\n private readonly template: string,\n readonly attribution: string,\n readonly tileSize = 256,\n readonly maxZoom = 19,\n private readonly subdomains: readonly string[] = [],\n ) {}\n\n urlFor(z: number, x: number, y: number): string {\n let url = this.template\n .replace(\"{z}\", String(z))\n .replace(\"{x}\", String(x))\n .replace(\"{y}\", String(y));\n if (this.subdomains.length > 0) {\n const idx = (x + y) % this.subdomains.length;\n url = url.replace(\"{s}\", this.subdomains[idx]);\n }\n\n return url;\n }\n}\n\n/**\n * Declarative description of one raster XYZ tile provider \u2014 the shape\n * of an entry in [tile-sources.json] and of the argument to\n * `registerTileSource`. Everything the renderer needs to construct a\n * concrete {@link TileSource} lives here; the TypeScript is generic\n * over these entries and hardcodes no provider URLs.\n */\nexport interface TileSourceSpec {\n /** Registry key; the persisted `map_tile_provider` value. */\n readonly id: string;\n\n /** Human-readable enum-variant label on the settings panel. */\n readonly label: string;\n\n /**\n * URL template with `{z}`/`{x}`/`{y}` placeholders and optional\n * `{s}` subdomain rotation. A provider that needs an API key\n * embeds it directly in the template it registers \u2014 keys never\n * pass through `plugin_config`, so they never appear in `save()`\n * output.\n */\n readonly template: string;\n\n /** `{s}` rotation pool; required non-empty iff `template` has `{s}`. */\n readonly subdomains: readonly string[];\n\n /** See {@link TileSource.attribution}. */\n readonly attribution: string;\n\n /** See {@link TileSource.tileSize}. Default 256. */\n readonly tile_size: number;\n\n /** See {@link TileSource.maxZoom}. Default 19. */\n readonly max_zoom: number;\n}\n\n/**\n * Validate + normalize an untrusted spec (a JSON entry or a\n * `registerTileSource` argument). Throws `TypeError` naming the\n * offending field; returns a frozen spec with defaults applied.\n */\nexport function parseTileSourceSpec(input: unknown): TileSourceSpec {\n if (typeof input !== \"object\" || input === null) {\n throw new TypeError(\"TileSourceSpec must be an object\");\n }\n\n const raw = input as Record<string, unknown>;\n const str = (key: string): string => {\n const v = raw[key];\n if (typeof v !== \"string\" || v.length === 0) {\n throw new TypeError(\n `TileSourceSpec.${key} must be a non-empty string`,\n );\n }\n\n return v;\n };\n\n const id = str(\"id\");\n const label = str(\"label\");\n const template = str(\"template\");\n const attribution = str(\"attribution\");\n for (const placeholder of [\"{z}\", \"{x}\", \"{y}\"]) {\n if (!template.includes(placeholder)) {\n throw new TypeError(\n `TileSourceSpec.template must contain \"${placeholder}\"`,\n );\n }\n }\n\n const rawSubdomains = raw[\"subdomains\"] ?? [];\n if (\n !Array.isArray(rawSubdomains) ||\n rawSubdomains.some((s) => typeof s !== \"string\" || s.length === 0)\n ) {\n throw new TypeError(\n \"TileSourceSpec.subdomains must be an array of non-empty strings\",\n );\n }\n\n const subdomains = Object.freeze([...rawSubdomains] as string[]);\n if (template.includes(\"{s}\") && subdomains.length === 0) {\n throw new TypeError(\n 'TileSourceSpec.template uses \"{s}\" but no subdomains were given',\n );\n }\n\n const num = (key: string, dflt: number): number => {\n const v = raw[key];\n if (v === undefined) {\n return dflt;\n }\n\n if (typeof v !== \"number\" || !Number.isFinite(v) || v <= 0) {\n throw new TypeError(\n `TileSourceSpec.${key} must be a positive number`,\n );\n }\n\n return v;\n };\n\n return Object.freeze({\n id,\n label,\n template,\n subdomains,\n attribution,\n tile_size: num(\"tile_size\", 256),\n max_zoom: num(\"max_zoom\", 19),\n });\n}\n\n/**\n * 32-bit FNV-1a over a string, hex-encoded. Fingerprints a spec's\n * fetch-relevant fields into the {@link TileSource.id} cache key.\n */\nfunction fnv1a(s: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < s.length; i++) {\n h ^= s.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n\n return (h >>> 0).toString(16);\n}\n\n/**\n * The set of known tile providers: the bundled entries from\n * [tile-sources.json] plus any registered at runtime via\n * `registerTileSource`. One instance exists per JS realm ({@link\n * TILE_SOURCES}) \u2014 the plugin realm's is the source of truth for the\n * settings-panel enum; the worker realm's resolves ids at render time.\n * The realms need no eager mirroring: every `setPluginConfig` / `init`\n * control message carries the resolved spec for the config's\n * `map_tile_provider` alongside the config itself, so a worker can\n * never hold a config whose spec it lacks.\n */\nexport class TileSourceRegistry {\n private _specs = new Map<string, TileSourceSpec>();\n\n constructor(seed: readonly unknown[]) {\n for (const entry of seed) {\n const spec = parseTileSourceSpec(entry);\n this._specs.set(spec.id, spec);\n }\n }\n\n /**\n * Add (or replace, by id) a provider. Validates via\n * {@link parseTileSourceSpec} and returns the normalized spec.\n * Replacement is safe for live charts: the cache identity below is\n * content-derived, so a changed template yields a new cache key\n * and the tile layer drops its stale textures on next bind.\n */\n register(input: unknown): TileSourceSpec {\n const spec = parseTileSourceSpec(input);\n this._specs.set(spec.id, spec);\n return spec;\n }\n\n /** Every known spec, bundled first, in insertion order. */\n list(): readonly TileSourceSpec[] {\n return [...this._specs.values()];\n }\n\n /** The spec registered under `id`, or `undefined` if unknown. */\n specFor(id: string): TileSourceSpec | undefined {\n return this._specs.get(id);\n }\n\n /**\n * Resolve a `map_tile_provider` id to a concrete `TileSource`.\n * Unknown ids fall back to the first bundled entry so a\n * misconfigured `plugin_config` never produces a blank map \u2014 and\n * so a config restored *before* its custom source is registered\n * degrades to the default basemap until the next config forward\n * carries the registered spec.\n */\n sourceFor(id: string): TileSource {\n const spec = this._specs.get(id) ?? this._specs.values().next().value!;\n\n // Cache identity = id + content hash of the fetch-relevant\n // fields. Re-registering an id with a different template MUST\n // invalidate `TileCache` entries (keyed on `TileSource.id`)\n // or stale tiles from the old URL would keep rendering; the\n // hash does that without any cross-realm revision state.\n const fingerprint = fnv1a(\n `${spec.template}\u0000${spec.subdomains.join(\",\")}`,\n );\n\n return new TemplatedTileSource(\n `${spec.id}@${fingerprint}`,\n spec.template,\n spec.attribution,\n spec.tile_size,\n spec.max_zoom,\n spec.subdomains,\n );\n }\n}\n\n/**\n * Realm-wide provider registry, seeded from [tile-sources.json]. A\n * malformed bundled entry fails loudly here, at first import.\n */\nexport const TILE_SOURCES = new TileSourceRegistry(TILE_SOURCE_SEED);\n\n/**\n * Read-only listing of every known tile provider (bundled + runtime-\n * registered), in settings-panel enum order. Public package export.\n */\nexport function tileSources(): readonly TileSourceSpec[] {\n return TILE_SOURCES.list();\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { View } from \"@perspective-dev/client\";\nimport { TILE_SOURCES } from \"../map/tile-source\";\nimport type { ColumnDataMap } from \"../data/view-reader\";\nimport type { WebGLContextManager } from \"../webgl/context-manager\";\nimport type { ZoomController } from \"../interaction/zoom-controller\";\nimport type { HostSink } from \"../interaction/tooltip-controller\";\n\nexport interface ChartImplementation {\n uploadAndRender(\n glManager: WebGLContextManager,\n columns: ColumnDataMap,\n startRow: number,\n endRow: number,\n ): void;\n\n /**\n * The single render entrypoint. Every render-triggering caller \u2014\n * upload chunks, zoom / pan, resize, theme invalidation,\n * host-driven redraws \u2014 calls this. Routes through the\n * module-level scheduler ([render/scheduler.ts]) so concurrent\n * calls collapse to one `_fullRender` per RAF and the host\n * blitter receives one bitmap per frame per chart.\n *\n * The returned promise resolves after this entry's `_fullRender`\n * + `awaitGpuFence` + `endFrame` chain completes \u2014 independent\n * of other charts in the same RAF, which run their fence waits\n * in parallel.\n *\n * The synchronous-render bypass for `snapshotPng` (calls\n * `_fullRender` directly, skips `endFrame`) is the only\n * sanctioned exception and lives inside the worker renderer.\n */\n requestRender(glManager: WebGLContextManager): Promise<void>;\n\n /**\n * The chart-specific GL frame builder. Submits the GL draw commands\n * and stashes the frame's 2D-canvas draws (gridlines + chrome) for\n * the scheduler to flush after `awaitGpuFence`. The scheduler wraps\n * this with fence + 2D flush + `endFrame`; callers must not invoke\n * it directly \u2014 `snapshotPng` uses {@link renderFrameSync} instead.\n */\n _fullRender(glManager: WebGLContextManager): void;\n\n /**\n * Synchronous full frame (GL + 2D) for the `snapshotPng` bypass,\n * which sits outside the scheduler and needs the gridline/chrome\n * canvases painted before compositing. Runs the GL pass then flushes\n * the deferred 2D draws immediately, skipping the fence split and\n * `endFrame` so the GL backbuffer stays intact for `gl.readPixels`.\n */\n renderFrameSync(glManager: WebGLContextManager): void;\n\n /**\n * Hand the current View to the chart so it can make on-demand\n * per-row queries (for lazy tooltip column lookups). Called on\n * every `draw`; the chart disposes any prior fetcher and clears\n * dependent UI (pinned tooltip) so stale rows never surface.\n *\n * TODO: pinned tooltips are dismissed on view update today. A\n * future enhancement is to keep a pinned tooltip visible (with its\n * captured data) until the user dismisses it, even after the\n * underlying view no longer contains that row.\n */\n setView?(view: View): void;\n\n /**\n * Set the gridline canvas (behind WebGL, for gridlines).\n */\n setGridlineCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;\n\n /**\n * Set the chrome canvas (above WebGL, for axes/labels/legend/tooltip).\n */\n setChromeCanvas?(canvas: HTMLCanvasElement | OffscreenCanvas): void;\n\n /**\n * Install the renderer's overlay-present hook.\n */\n setOverlayPresenter?(cb: () => void): void;\n\n /**\n * Hand the chart a pre-computed CSS-variable map produced on the\n * main thread via `snapshotThemeVars(el)`, which it can decode into\n * a full `Theme` without touching the DOM (charts always run inside\n * the renderer scope, which has no `getComputedStyle`).\n */\n setTheme?(vars: Record<string, string>): void;\n\n /**\n * Set the zoom controller for interactive zoom/pan.\n */\n setZoomController?(zc: ZoomController): void;\n\n /**\n * Wire the chart's `TooltipController` for virtual-dispatch hover /\n * click events forwarded from the host. The renderer drives\n * `dispatchHover` / `dispatchLeave` / `dispatchClick` /\n * `dispatchDblClick` from `InteractionEvent`s; the supplied\n * `HostSink` posts pin / dismiss / setCursor intents back to the\n * host so the resulting DOM mutations happen there (the renderer\n * scope has no DOM in worker mode, and uses the same channel\n * in-process for symmetry).\n */\n attachTooltip?(host: HostSink): void;\n\n /**\n * Set the column slot config (with nulls for empty slots).\n */\n setColumnSlots?(slots: (string | null)[]): void;\n\n /**\n * Set group_by and split_by config from the viewer.\n */\n setViewPivots?(groupBy: string[], splitBy: string[]): void;\n\n /**\n * Set column type schema from the view (e.g., { \"col\": \"date\" }).\n */\n setColumnTypes?(schema: Record<string, string>): void;\n\n /**\n * Set the source-column types used for `group_by` level lookups \u2014\n * sourced from `table.schema()` + `view.expression_schema()`. Used\n * by categorical-axis charts to detect numeric / date / boolean\n * group_by levels (which are not keyed in `view.schema()` because\n * they surface as `__ROW_PATH_N__` columns).\n */\n setGroupByTypes?(schema: Record<string, string>): void;\n\n /**\n * Set per-column render config (the second argument to `plugin.restore`).\n * Key is the aggregate base name; value is an open object whose\n * `chart_type` / `stack` fields are consumed by the Y-bar glyph router.\n */\n setColumnsConfig?(cfg: Record<string, any>): void;\n\n /**\n * Set the plugin's default glyph type. Used by the Y-series chart\n * family (Y Bar / Y Line / Y Scatter / Y Area): each tag is the same\n * `BarChart` impl with a different starting `chart_type` applied to\n * columns that lack an explicit entry in `columns_config`.\n */\n setDefaultChartType?(chartType: string): void;\n\n /**\n * Set the faceting config: one small-multiple sub-plot per\n * `split_by` group, optional shared axes, coordinated tooltip, and\n * zoom routing mode. Seeded from `DEFAULT_FACET_CONFIG` at init;\n * `plugin_config.facet_mode` / `facet_zoom_mode` override the\n * matching fields via `AbstractChart.setPluginConfig`.\n */\n setFacetConfig?(cfg: FacetConfig): void;\n\n /**\n * Set the plugin-scoped global configuration \u2014 the values backing\n * `plugin_config_schema` / `plugin_config` in `restore`. Replaces\n * the previous module-level constants (`LINE_WIDTH_PX`,\n * `POINT_SIZE_PX`, `BAND_INNER_FRAC`, `BAR_INNER_PAD`,\n * `WICK_WIDTH_PX`, `OHLC_LINE_WIDTH_PX`, `AUTO_ALT_Y_AXIS`) plus\n * the faceted/series zoom-mode semantics described in\n * {@link PluginConfig}.\n */\n setPluginConfig?(cfg: PluginConfig): void;\n\n /**\n * Drop any cached theme values so the next render re-reads CSS\n * variables. Driven from `plugin.restyle()`.\n */\n invalidateTheme?(): void;\n\n /**\n * Clear the `domain_mode: \"expand\"` accumulator state so the next\n * data load starts from the current data extent. Driven from\n * `resetAllZooms` (the user clicked \"Reset Zoom\"). View-config\n * mutations route through `AbstractChart`'s `setColumnSlots` /\n * `setViewPivots` / `setColumnTypes` setters, which call the same\n * hook internally.\n */\n resetExpandedDomain?(): void;\n\n /**\n * Silently clear any active selection state (pinned tooltip) WITHOUT\n * emitting selection events. Driven from the host's `deselect`\n * message \u2014 its global filter bar removed a clause this chart's\n * selection contributed, so an unselect emit would double-mutate the\n * host's filter set.\n */\n deselect?(): void;\n\n repaintChrome?(): void;\n\n destroy(): void;\n}\n\nexport interface FacetConfig {\n /**\n * \"grid\" = small multiples (default); \"overlay\" = legacy single-plot.\n */\n facet_mode: \"grid\" | \"overlay\";\n\n /**\n * Share one bottom X axis across all columns of facets.\n */\n shared_x_axis: boolean;\n\n /**\n * Share one left Y axis across all rows of facets.\n */\n shared_y_axis: boolean;\n\n /**\n * Paint a tooltip in every facet (otherwise only the source facet).\n */\n coordinated_tooltip: boolean;\n\n /**\n * \"shared\" = one viewport for all facets; \"independent\" = per-facet.\n */\n zoom_mode: \"shared\" | \"independent\";\n\n /**\n * Pixel gap between adjacent facet cells in grid mode.\n */\n facet_padding: number;\n}\n\nexport const DEFAULT_FACET_CONFIG: FacetConfig = {\n facet_mode: \"grid\",\n shared_x_axis: true,\n shared_y_axis: true,\n coordinated_tooltip: false,\n zoom_mode: \"shared\",\n facet_padding: 6,\n};\n\n/**\n * Plugin-scoped global configuration \u2014 the user-facing settings backing\n * `plugin_config_schema()` / the `plugin_config` slot in `restore`.\n *\n * Each chart type's `plugin_config_schema` returns only the fields that\n * are applicable for that chart (see `applicable_plugin_fields` on\n * `ChartTypeConfig`); inapplicable fields are hidden in the UI. The\n * chart impl receives the full struct on `setPluginConfig` and reads\n * only the fields its render / build pipeline cares about.\n *\n * Some fields overlap with {@link FacetConfig} (`facet_mode`,\n * `facet_zoom_mode`); the base `AbstractChart.setPluginConfig` syncs\n * those onto `_facetConfig` so deep render code keeps reading the\n * single facet struct it already does. `series_zoom_mode` toggles the\n * categorical-Y chart base's `_autoFitValue` flag.\n */\nexport interface PluginConfig {\n /**\n * Auto-detect Y dual-axis splits when aggregate magnitudes differ\n * by more than `DUAL_Y_RATIO_THRESHOLD`\u00D7. Series charts only.\n * Replaces the `AUTO_ALT_Y_AXIS` compile-time toggle.\n */\n auto_alt_y_axis: boolean;\n\n /**\n * Faceting strategy when `split_by` is non-empty.\n *\n * - `\"grid\"` \u2014 one small-multiple sub-plot per split group.\n * - `\"overlay\"` \u2014 a single plot: cartesian charts differentiate\n * split groups by color; the categorical band pipeline (series\n * charts) stacks splits within each aggregate's band slot.\n * Synced into `_facetConfig.facet_mode`.\n *\n * The default differs by family via\n * `ChartTypeConfig.plugin_field_defaults`: cartesian / density /\n * map chart types default to `\"grid\"`, the series / financial\n * band-pipeline types to `\"overlay\"` (their historical split\n * rendering). Series charts REBUILD on a mode change \u2014 grid mode\n * keys the stack ladder per split (`facetSplits` in\n * `buildSeriesPipeline`) so each facet grows from its own\n * baseline.\n */\n facet_mode: \"grid\" | \"overlay\";\n\n /**\n * Faceted-cartesian zoom routing. `\"shared\"` \u2014 one viewport across\n * all facets; `\"independent\"` \u2014 wheel/pan routes to the facet under\n * the cursor with its own viewport. Synced into\n * `_facetConfig.zoom_mode`.\n */\n facet_zoom_mode: \"shared\" | \"independent\";\n\n /**\n * Series-chart value-axis behavior on zoom.\n *\n * - `\"dynamic\"` \u2014 value axis refits to the visible categorical\n * slice (current default; `CategoricalYChart._autoFitValue` =\n * true).\n * - `\"fixed\"` \u2014 value axis stays pinned to the full-data extent.\n */\n series_zoom_mode: \"fixed\" | \"dynamic\";\n\n /**\n * Anchor the value axis to zero \u2014 when true, `0` is forced into\n * the rendered domain even if all data sits well above or below\n * it. Natural for bar / area glyphs (which grow from the zero\n * baseline) and surprising for line / scatter (where the\n * interesting variation often lives far from zero). Per-chart-type\n * defaults route through `ChartTypeConfig.plugin_field_defaults`:\n * `true` for Y Bar / Y Area / X Bar, `false` elsewhere.\n */\n include_zero: boolean;\n\n /**\n * Domain accumulation policy across successive `View` updates.\n *\n * - `\"fit\"` \u2014 every update recomputes the affected domains from\n * the current data extent. Can grow or shrink frame-to-frame.\n * - `\"expand\"` \u2014 the affected domains monotonically *grow*: each\n * update unions the new data extent with the previously rendered\n * extent, so once a value is in scope it stays in scope. Reset\n * by the \"Reset Zoom\" button, view-config changes (group_by /\n * split_by / column-slot / column-type), or toggling back to\n * `\"fit\"`.\n *\n * AXIS SCOPE differs by family: cartesian charts (X/Y Scatter,\n * X/Y Line, Density, Maps) apply it to BOTH axes plus the\n * color/size scales (categorical string axes opt out \u2014 slot\n * indices are frame-local); the categorical band pipeline (series\n * / financial) applies it to the VALUE axis only \u2014 Y for the\n * Y-family, X for X Bar \u2014 while the category axis always fits, so\n * a streaming numeric/datetime `group_by` axis releases departed\n * categories instead of pinning to its history.\n */\n domain_mode: \"fit\" | \"expand\";\n\n /**\n * Width of polyline glyphs in CSS pixels (multiplied by DPR at GL\n * upload). Replaces the duplicated `LINE_WIDTH_PX` constants in\n * the cartesian + series line glyphs.\n */\n line_width_px: number;\n\n /**\n * Diameter of scatter point glyphs in CSS pixels. Replaces\n * `POINT_SIZE_PX`.\n */\n point_size_px: number;\n\n /**\n * Fraction of each category band occupied by its slot(s). Replaces\n * `BAND_INNER_FRAC`. Affects buffer contents \u2014 takes effect on\n * next data load.\n */\n band_inner_frac: number;\n\n /**\n * Relative inner padding between adjacent slots within a band.\n * Replaces `BAR_INNER_PAD`. Affects buffer contents \u2014 takes effect\n * on next data load.\n */\n bar_inner_pad: number;\n\n /**\n * Candlestick wick stroke width in CSS pixels. Replaces\n * `WICK_WIDTH_PX`.\n */\n wick_width_px: number;\n\n /**\n * OHLC bar stroke width in CSS pixels. Replaces\n * `OHLC_LINE_WIDTH_PX`.\n */\n ohlc_line_width_px: number;\n\n /**\n * density splat radius in CSS pixels. Each data point is\n * rasterized as a soft disk of this radius into the accumulation\n * FBO before the gradient LUT pass resolves to a heat color.\n */\n gradient_radius_px: number;\n\n /**\n * density per-splat intensity multiplier. Controls how\n * fast the density grows when points overlap (low values produce\n * a smoother, more diffuse field; high values produce sharper\n * peaks).\n */\n gradient_intensity: number;\n\n /**\n * density clamp on the maximum accumulated heat used for\n * the gradient-LUT lookup. Lower values saturate sooner (more of\n * the LUT's hot stops show up); higher values stay cooler. In\n * every mode this controls the alpha (intensity) ramp; in\n * `density` mode it also drives the hue, and in `signed` mode it\n * scales the signed-sum-to-hue mapping.\n */\n gradient_heat_max: number;\n\n /**\n * density color-reduction mode. Controls how each pixel's\n * stack of overlapping splats is reduced to a single LUT-t / alpha\n * pair in the resolve pass.\n *\n * - `mean` (default) \u2014 hue is the density-weighted average of\n * per-point color-t. Reads as \"the typical color-column value\n * in this region.\" Uses robust (5th/95th-percentile) bounds so\n * one outlier can't compress the rest of the data toward the\n * gradient midpoint.\n * - `density` \u2014 ignore the color column even when wired; hue and\n * alpha both follow density. Reads as \"where do points cluster.\"\n * Useful when the color column is attached for tooltip lookup\n * only.\n * - `extreme` \u2014 keep the per-pixel maximum signed deviation of\n * `t - 0.5` (split into positive and negative channels, MAX-\n * blended). Reads as \"where are the outliers.\" Density still\n * drives alpha so a single-point extreme fades naturally.\n * Requires a second framebuffer; uses MRT on WebGL2 hardware\n * with `OES_draw_buffers_indexed`, two passes otherwise.\n * - `signed` \u2014 accumulate signed `t - 0.5` and let positive vs\n * negative cancel out. Reads as \"net positive vs net negative\n * in each region.\" Requires a float-capable framebuffer; on\n * `UNSIGNED_BYTE` fallback hardware degrades silently to\n * `mean` with a one-line console warning.\n */\n gradient_color_mode: \"mean\" | \"density\" | \"extreme\" | \"signed\";\n\n /**\n * Map basemap tile provider \u2014 a `TileSourceSpec` id from the\n * tile-source registry ([map/tile-sources.json] entries plus any\n * runtime `registerTileSource` additions). Applies only to map\n * plugin tags (`map-scatter`, `map-line`, `map-density`); other\n * charts ignore the field. The default is the JSON's FIRST entry\n * (reordering the file changes the default), and unknown ids fall\n * back to that same entry rather than blanking the map.\n */\n map_tile_provider: string;\n\n /**\n * Map basemap alpha (0..1). Pre-multiplied into the tile fragment\n * shader's output so the chart's glyph layer composites over a\n * dimmer or brighter version of the basemap. `1.0` (default)\n * shows the tiles at full opacity.\n */\n map_tile_alpha: number;\n\n /**\n * Map plugins only. `true` (default): standard numeric axes in the\n * usual cartesian gutters, with tick labels in degrees\n * longitude/latitude (`122.4\u00B0W`) rather than Mercator meters.\n * `false`: no axes, and the plot is full-bleed \u2014 the basemap fills\n * the entire canvas, minus only the sidebar legend gutter when a\n * legend is actually shown. Gridlines are never drawn in map mode\n * \u2014 the gridline canvas composites BELOW the GL layer, so opaque\n * basemap tiles would hide them.\n */\n numeric_axes: boolean;\n\n /**\n * Legend presentation mode. `\"auto\"` (default) resolves per frame\n * to `\"floating\"` when every entry fits the default floating panel\n * without scrolling (\u2264 7 entries; continuous gradient legends\n * always qualify) and to `\"sidebar\"` otherwise \u2014 see\n * `resolveLegendMode`. Treemap overrides the default to\n * `\"sidebar\"` (a floating panel over edge-to-edge tiles always\n * occludes data).\n */\n legend_mode: \"auto\" | \"sidebar\" | \"none\" | \"floating\";\n\n /**\n * Floating-panel sizing regime. `\"auto\"` (default) sizes the panel\n * to its CONTENT every frame \u2014 the height hugs the entry rows\n * exactly, and the width hugs the widest entry label (measured on\n * the chrome canvas). `\"fixed\"` uses the saved `legend_width_px` /\n * `legend_height_px` verbatim.\n *\n * Applies to `legend_mode: \"floating\"` ONLY; the sidebar gutter is\n * always `legend_width_px` (its height is the plot's). Dragging a\n * resize handle switches an auto panel to `\"fixed\"` \u2014 otherwise\n * the gesture would be undone by the next paint \u2014 and\n * double-clicking a resize handle switches it back.\n */\n legend_size_mode: LegendSizeMode;\n\n /**\n * Legend width in CSS pixels. `0` (default) = automatic \u2014 each\n * chart family keeps its historical gutter width (80\u201396px). In\n * `\"sidebar\"` mode this is the full right-gutter width; in\n * `\"floating\"` mode it is the panel width. Clamped at paint time\n * to at most half the canvas width so a saved wide legend cannot\n * crush a small panel. Ignored by a floating panel in\n * `legend_size_mode: \"auto\"`.\n */\n legend_width_px: number;\n\n /**\n * Floating-legend panel height in CSS pixels. Ignored in\n * `\"sidebar\"` mode (the legend spans the plot height) and by a\n * floating panel in `legend_size_mode: \"auto\"`. Clamped at paint\n * time to the canvas height.\n */\n legend_height_px: number;\n\n /**\n * Canvas corner that `legend_x` / `legend_y` are measured FROM.\n * Floating mode only. The panel keeps its distance to this corner\n * across panel resizes \u2014 anchor `\"bottom-right\"` with small\n * offsets stays glued to the bottom-right.\n */\n legend_anchor: LegendAnchor;\n\n legend_x: number;\n legend_y: number;\n legend_opacity: number;\n\n /** Per-column width cap for tooltip grid cells, in CSS pixels. */\n tooltip_max_column_px: number;\n\n /** Tooltip background/border alpha (0..1). */\n tooltip_opacity: number;\n}\n\nexport type LegendAnchor =\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-right\";\n\nexport type LegendSizeMode = \"auto\" | \"fixed\";\n\nexport const DEFAULT_PLUGIN_CONFIG: PluginConfig = {\n auto_alt_y_axis: false,\n facet_mode: \"grid\",\n facet_zoom_mode: \"shared\",\n series_zoom_mode: \"dynamic\",\n include_zero: false,\n domain_mode: \"expand\",\n line_width_px: 2.0,\n point_size_px: 8.0,\n band_inner_frac: 0.5,\n bar_inner_pad: 0.1,\n wick_width_px: 1.0,\n ohlc_line_width_px: 1.0,\n gradient_radius_px: 32.0,\n gradient_intensity: 0.6,\n gradient_heat_max: 4.0,\n gradient_color_mode: \"mean\",\n map_tile_provider: TILE_SOURCES.list()[0].id,\n map_tile_alpha: 1.0,\n numeric_axes: true,\n legend_mode: \"auto\",\n legend_size_mode: \"auto\",\n legend_width_px: 0,\n legend_height_px: 160,\n legend_anchor: \"top-right\",\n legend_x: 0,\n legend_y: 0,\n legend_opacity: 0.8,\n tooltip_max_column_px: 160,\n tooltip_opacity: 0.8,\n};\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type {\n DateFormatConfig,\n NumberFormatConfig,\n} from \"@perspective-dev/viewer/src/ts/column-format.js\";\n\n/**\n * The chart plugin's default per-column formats, declared to the viewer in\n * `column_config_schema()` and applied by the render path under sparse or\n * absent configs.\n */\nexport const CHART_NUMBER_DEFAULTS: NumberFormatConfig = {\n notation: \"compact\",\n compactDisplay: \"short\",\n minimumFractionDigits: 0,\n maximumFractionDigits: 1,\n};\n\nexport const CHART_DATETIME_DEFAULTS: DateFormatConfig = {\n dateStyle: \"medium\",\n timeStyle: \"disabled\",\n};\n\nexport const CHART_DATE_DEFAULTS: DateFormatConfig = {\n dateStyle: \"medium\",\n};\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { InteractionEvent } from \"../transport/protocol\";\n\n/**\n * Captures wheel / pointer events on the GL canvas, normalizes coords\n * to canvas-relative CSS pixels, and emits semantic\n * {@link InteractionEvent}s to the Renderer over its transport. The\n * Renderer owns the `ZoomController`s and runs the actual hit-test +\n * apply logic \u2014 see `applyWheel` / `applyPan` in `zoom-router.ts`.\n *\n * Pointer capture is set on `pointerdown` and released on `pointerup`\n * so drags continue to deliver `pointermove` events when the cursor\n * leaves the canvas.\n */\nexport class RawEventForwarder {\n private _element: HTMLElement | null = null;\n private _emit: ((e: InteractionEvent) => void) | null = null;\n private _pointerId: number | null = null;\n\n private _onWheel: ((e: WheelEvent) => void) | null = null;\n private _onPointerDown: ((e: PointerEvent) => void) | null = null;\n private _onPointerMove: ((e: PointerEvent) => void) | null = null;\n private _onPointerUp: ((e: PointerEvent) => void) | null = null;\n private _onPointerLeave: (() => void) | null = null;\n private _onClick: ((e: MouseEvent) => void) | null = null;\n private _onDblClick: ((e: MouseEvent) => void) | null = null;\n\n attach(element: HTMLElement, emit: (e: InteractionEvent) => void): void {\n this.detach();\n this._element = element;\n this._emit = emit;\n\n this._onWheel = (e: WheelEvent) => {\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n\n // `preventDefault` is fired unconditionally so the page\n // does not scroll while the chart is hovered \u2014 the worker\n // may still no-op if the cursor is outside any facet's\n // plot rect.\n e.preventDefault();\n emit({ type: \"wheel\", mx, my, deltaY: e.deltaY });\n };\n\n this._onPointerDown = (e: PointerEvent) => {\n // Only forward primary-button pointerdowns. Right/middle clicks must\n // reach the panel's `contextmenu` handler \u2014 capturing the pointer\n // here would otherwise swallow the right-click.\n if (e.button !== 0) {\n return;\n }\n\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n element.setPointerCapture(e.pointerId);\n this._pointerId = e.pointerId;\n emit({ type: \"pointerdown\", mx, my, pointerId: e.pointerId });\n };\n\n this._onPointerMove = (e: PointerEvent) => {\n const rect = element.getBoundingClientRect();\n const mx = e.clientX - rect.left;\n const my = e.clientY - rect.top;\n emit({ type: \"pointermove\", mx, my });\n };\n\n this._onPointerUp = (e: PointerEvent) => {\n if (this._pointerId !== null) {\n try {\n element.releasePointerCapture(this._pointerId);\n } catch {\n // capture may have already been released\n }\n\n this._pointerId = null;\n }\n\n void e;\n emit({ type: \"pointerup\" });\n };\n\n // Pointerleave gives the renderer a single signal that the\n // cursor truly exited the canvas \u2014 used for tooltip dismissal.\n // Hover + drag both ride the `pointermove` stream above, so no\n // parallel `mousemove` channel exists.\n this._onPointerLeave = () => {\n emit({ type: \"pointerleave\" });\n };\n\n this._onClick = (e: MouseEvent) => {\n const rect = element.getBoundingClientRect();\n emit({\n type: \"click\",\n mx: e.clientX - rect.left,\n my: e.clientY - rect.top,\n });\n };\n\n this._onDblClick = (e: MouseEvent) => {\n const rect = element.getBoundingClientRect();\n emit({\n type: \"dblclick\",\n mx: e.clientX - rect.left,\n my: e.clientY - rect.top,\n });\n };\n\n element.addEventListener(\"wheel\", this._onWheel, { passive: false });\n element.addEventListener(\"pointerdown\", this._onPointerDown);\n element.addEventListener(\"pointermove\", this._onPointerMove);\n element.addEventListener(\"pointerup\", this._onPointerUp);\n element.addEventListener(\"pointerleave\", this._onPointerLeave);\n element.addEventListener(\"click\", this._onClick);\n element.addEventListener(\"dblclick\", this._onDblClick);\n }\n\n detach(): void {\n if (this._element) {\n if (this._onWheel) {\n this._element.removeEventListener(\"wheel\", this._onWheel);\n }\n\n if (this._onPointerDown) {\n this._element.removeEventListener(\n \"pointerdown\",\n this._onPointerDown,\n );\n }\n\n if (this._onPointerMove) {\n this._element.removeEventListener(\n \"pointermove\",\n this._onPointerMove,\n );\n }\n\n if (this._onPointerUp) {\n this._element.removeEventListener(\n \"pointerup\",\n this._onPointerUp,\n );\n }\n\n if (this._onPointerLeave) {\n this._element.removeEventListener(\n \"pointerleave\",\n this._onPointerLeave,\n );\n }\n\n if (this._onClick) {\n this._element.removeEventListener(\"click\", this._onClick);\n }\n\n if (this._onDblClick) {\n this._element.removeEventListener(\"dblclick\", this._onDblClick);\n }\n }\n\n this._element = null;\n this._emit = null;\n this._pointerId = null;\n this._onPointerLeave = null;\n this._onClick = null;\n this._onDblClick = null;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { ViewConfig } from \"@perspective-dev/client\";\n\n/**\n * Detail payload for the `perspective-click` CustomEvent dispatched on\n * the `<perspective-viewer>` host when the user clicks a chart glyph.\n * Shape matches the equivalent type in `@perspective-dev/viewer-datagrid`\n * so consumers can listen to either plugin uniformly.\n */\nexport interface PerspectiveClickDetail {\n /**\n * Source-view row data \u2014 keys are column names, values are scalar\n * cell values. Empty `{}` when the click hit a non-leaf aggregate\n * (e.g. a treemap branch).\n */\n row: Record<string, unknown>;\n\n /**\n * Aggregate column(s) the click targeted. Single-entry for series /\n * heatmap / tree charts; multi-entry would only appear for plugins\n * that surface multiple measures per glyph (none today).\n */\n column_names: string[];\n\n /**\n * Pre-built `viewer.restore({ filter })` patch \u2014 concatenates the\n * group_by and split_by pivot values at the click target as\n * `[<col>, \"==\", <value>]` clauses.\n */\n config: Partial<ViewConfig>;\n\n /**\n * The source panel's `slot` name in a multi-panel `<perspective-viewer>`,\n * so the host can attribute the click to the originating panel. `undefined`\n * for a lone, unslotted viewer. Mirrors `PerspectiveSelectDetail.panel` and\n * the datagrid `PerspectiveClickDetail`.\n */\n panel?: string;\n}\n\nexport { PerspectiveSelectDetail } from \"@perspective-dev/viewer/src/ts/extensions.js\";\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { ThemeSnapshot } from \"./theme\";\n\n/**\n * CSS variables (and one inherited property) the chart renderer reads.\n * Host-only: workers can't call `getComputedStyle`, so this list (and\n * `snapshotThemeVars`) doesn't need to ship in the worker bundle.\n */\nconst THEME_VARS = [\n \"--psp-charts--font-family\",\n \"font-family\",\n \"--psp--background-color\",\n \"--psp-charts--axis-ticks--color\",\n \"--psp--color\",\n \"--psp-charts--axis-lines--color\",\n \"--psp-charts--gridline--color\",\n \"--psp-charts--gradient--background\",\n \"--psp-charts--full-gradient--background\",\n \"--psp-charts--legend--color\",\n \"--psp-charts--legend-border--color\",\n \"--psp-charts--tooltip--background\",\n \"--psp-charts--tooltip--color\",\n \"--psp-charts--tooltip--border-color\",\n \"--psp-charts--area--opacity\",\n \"--psp-charts--heatmap-gap--px\",\n \"--psp-charts--sunburst-gap--px\",\n];\n\n/**\n * Capture every CSS variable the renderer cares about into a\n * structured-cloneable map. Series-palette colours are walked until the\n * first missing var.\n */\nexport function snapshotThemeVars(el: Element): ThemeSnapshot {\n const style = getComputedStyle(el);\n const out: ThemeSnapshot = {};\n for (const v of THEME_VARS) {\n const raw = style.getPropertyValue(v).trim();\n if (raw) {\n out[v] = raw;\n }\n }\n\n for (let i = 1; ; i++) {\n const key = `--psp-charts--series-${i}--color`;\n const raw = style.getPropertyValue(key).trim();\n if (!raw) {\n break;\n }\n\n out[key] = raw;\n }\n\n return out;\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { FontFaceDescriptor } from \"../transport/protocol\";\n\n/**\n * Walk every accessible `@font-face` rule in the document and collect a\n * descriptor list ready for forwarding to a Web Worker, where each\n * entry is reconstituted via `new FontFace(family, src, descriptors)`\n * and registered in the worker's own `self.fonts` set.\n *\n * Background: a `Worker` has its own `FontFaceSet` distinct from the\n * document's. Fonts loaded into `document.fonts` (by `<link>`,\n * `@font-face`, or programmatic `FontFace`) are *not* visible to the\n * worker \u2014 Canvas2D `ctx.font` lookups inside the worker fall back to\n * the platform default if the family isn't in `self.fonts`. This\n * helper bridges that gap for the in-CSS case.\n *\n * # CORS / security caveats\n *\n * 1. **Cross-origin stylesheets without permissive CORS** throw\n * `SecurityError` on `cssRules` access, and we silently skip them.\n * Their `@font-face` rules are unreachable to JS regardless of\n * where the worker would re-load them, so this is the same\n * fundamental limitation the document itself has.\n *\n * 2. **Font URLs are absolutized against the parent stylesheet's\n * `href`** before forwarding. The worker's own script URL is a\n * Blob URL produced by `WorkerPlugin`, so relative URLs in the raw\n * `src:` declaration would resolve against the Blob origin (i.e.\n * fail). Callers should treat the absolute URLs as the canonical\n * source.\n *\n * 3. **The actual font fetch issued by `face.load()` in the worker\n * is a fresh cross-origin request from the worker scope.** The\n * font server must respond with `Access-Control-Allow-Origin`\n * (e.g. `*` or the page origin) and an appropriate\n * `Access-Control-Allow-Headers` policy if any non-simple headers\n * are involved. A \"no-cors\" / opaque response is *not* usable\n * here: `FontFace.load()` rejects on opaque responses, and even\n * if it didn't, painted glyphs would taint the canvas and break\n * `getImageData`. Same-origin fonts (including `data:` URIs)\n * sidestep this entirely.\n *\n * 4. **Programmatic fonts** (e.g. `document.fonts.add(new\n * FontFace(name, source))`) are *not* captured by this walker \u2014\n * they don't appear in any stylesheet's `cssRules`. Iterating\n * `document.fonts` directly would catch them, but `FontFace`\n * instances don't expose their source URL or buffer post-\n * construction, so there's no public path to forward them. If a\n * test or app needs that, it must register the same fonts in the\n * worker explicitly.\n */\nexport function snapshotFontFaces(): FontFaceDescriptor[] {\n const out: FontFaceDescriptor[] = [];\n for (const sheet of Array.from(document.styleSheets)) {\n let rules: CSSRuleList;\n try {\n rules = sheet.cssRules;\n } catch {\n // Cross-origin stylesheet without permissive CORS \u2014 its\n // `@font-face` rules are unreachable to JS. See caveat (1).\n continue;\n }\n\n const base = sheet.href ?? document.baseURI;\n for (const rule of Array.from(rules)) {\n if (!(rule instanceof CSSFontFaceRule)) {\n continue;\n }\n\n const style = rule.style;\n const rawFamily = style.getPropertyValue(\"font-family\").trim();\n const rawSrc = style.getPropertyValue(\"src\").trim();\n if (!rawFamily || !rawSrc) {\n continue;\n }\n\n out.push({\n // CSSOM serializes multi-word family names with their\n // CSS quotes preserved (e.g. `\"Roboto Mono\"`). The\n // `FontFace` constructor *doesn't* unquote on parse \u2014\n // Chromium stores the literal input and re-quotes /\n // escapes on `face.family` getter access, yielding\n // `\"\\\"Roboto Mono\\\"\"` and a name that no `ctx.font`\n // lookup can match. Strip one layer of matching outer\n // quotes here so the worker's font set keys align\n // with how Canvas2D resolves family names.\n family: stripOuterQuotes(rawFamily),\n src: resolveSrcUrls(rawSrc, base),\n style: optional(style, \"font-style\"),\n weight: optional(style, \"font-weight\"),\n stretch: optional(style, \"font-stretch\"),\n unicodeRange: optional(style, \"unicode-range\"),\n variant: optional(style, \"font-variant\"),\n featureSettings: optional(style, \"font-feature-settings\"),\n display: optional(style, \"font-display\"),\n });\n }\n }\n\n return out;\n}\n\nfunction optional(\n style: CSSStyleDeclaration,\n prop: string,\n): string | undefined {\n const v = style.getPropertyValue(prop).trim();\n return v || undefined;\n}\n\n/**\n * Remove a single matching pair of outer `\"\u2026\"` or `'\u2026'` quotes from a\n * family name. CSSOM serializes multi-word `font-family` descriptor\n * values with their quotes preserved; `FontFace` then re-quotes on\n * serialization, producing the literal `\"\\\"Foo\\\"\"` double-quoting\n * observed in `face.family`. Stripping one layer here aligns the\n * stored family with what Canvas2D resolves at render time.\n */\nfunction stripOuterQuotes(s: string): string {\n if (s.length >= 2) {\n const first = s.charCodeAt(0);\n const last = s.charCodeAt(s.length - 1);\n if (first === last && (first === 0x22 || first === 0x27)) {\n return s.slice(1, -1);\n }\n }\n\n return s;\n}\n\n/**\n * Rewrite every `url(...)` token inside a CSS `src:` value to its\n * absolute form. Multi-source declarations (`url(...) format(...),\n * url(...) format(...)`) are handled by replacing each `url(...)`\n * chunk independently. See caveat (2).\n */\nfunction resolveSrcUrls(src: string, base: string): string {\n return src.replace(\n /url\\(\\s*(['\"]?)([^'\")]+)\\1\\s*\\)/g,\n (match, _quote, url) => {\n try {\n return `url(${new URL(url, base).href})`;\n } catch {\n return match;\n }\n },\n );\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Context2D } from \"../charts/canvas-types\";\nimport type { Theme } from \"../theme/theme\";\n\nexport type TooltipRow = string[];\n\nexport type TooltipContent = TooltipRow[];\n\nexport interface TooltipStyle {\n opacity: number;\n maxColumnPx: number;\n}\n\nexport const DEFAULT_TOOLTIP_STYLE: TooltipStyle = {\n opacity: 1.0,\n maxColumnPx: 160,\n};\n\nexport function tooltipStyleOf(cfg: {\n tooltip_opacity: number;\n tooltip_max_column_px: number;\n}): TooltipStyle {\n return {\n opacity: cfg.tooltip_opacity,\n maxColumnPx: cfg.tooltip_max_column_px,\n };\n}\n\nexport const NUMERIC_RE =\n /^[-+\u2212]?[$\u20AC\u00A3\u00A5]?\\s?\\d[\\d.,\u00A0\u202F\\s]*(?:[eE][-+]?\\d+|[KMB%])?$/;\n\nexport const TOOLTIP_ROW_HEIGHT = 16;\nexport const TOOLTIP_PADDING = 8;\nexport const TOOLTIP_COL_GAP = 8;\n\nexport interface MeasuredTooltipGrid {\n rows: string[][];\n\n colWidths: number[];\n\n colRightAlign: boolean[];\n\n boxW: number;\n boxH: number;\n}\n\n/**\n * Measure a tooltip grid under the current `ctx.font`.\n */\nexport function measureTooltipGrid(\n ctx: Context2D,\n grid: TooltipContent,\n maxColumnPx: number,\n): MeasuredTooltipGrid {\n const spanCap = maxColumnPx * 2 + TOOLTIP_COL_GAP;\n const colWidths: number[] = [];\n const colNumeric: boolean[] = [];\n const rows: string[][] = [];\n let spanWidth = 0;\n\n for (const row of grid) {\n if (row.length <= 1) {\n const text = ellipsize(ctx, row[0] ?? \"\", spanCap);\n rows.push([text]);\n spanWidth = Math.max(spanWidth, ctx.measureText(text).width);\n continue;\n }\n\n const cells: string[] = [];\n for (let j = 0; j < row.length; j++) {\n const original = row[j] ?? \"\";\n const text = ellipsize(ctx, original, maxColumnPx);\n cells.push(text);\n colWidths[j] = Math.max(\n colWidths[j] ?? 0,\n ctx.measureText(text).width,\n );\n if (j >= 1 && original !== \"\") {\n const numeric = NUMERIC_RE.test(original);\n colNumeric[j] =\n colNumeric[j] === undefined\n ? numeric\n : colNumeric[j] && numeric;\n }\n }\n\n rows.push(cells);\n }\n\n let columnsWidth = 0;\n for (let j = 0; j < colWidths.length; j++) {\n columnsWidth += colWidths[j] + (j > 0 ? TOOLTIP_COL_GAP : 0);\n }\n\n const innerW = Math.max(spanWidth, columnsWidth);\n return {\n rows,\n colWidths,\n colRightAlign: colWidths.map(\n (_, j) => (colNumeric[j] ?? false) && j >= 1,\n ),\n boxW: innerW + TOOLTIP_PADDING * 2,\n boxH: grid.length * TOOLTIP_ROW_HEIGHT + TOOLTIP_PADDING * 2 - 4,\n };\n}\n\n/**\n * Paint a measured tooltip grid at `(tx, ty)`.\n */\nexport function paintTooltipGrid(\n ctx: Context2D,\n measured: MeasuredTooltipGrid,\n tx: number,\n ty: number,\n theme: Theme,\n opacity: number,\n): void {\n const { rows, colWidths, colRightAlign, boxW, boxH } = measured;\n\n ctx.globalAlpha = Math.min(1, Math.max(0, opacity));\n ctx.fillStyle = theme.tooltipBg;\n ctx.strokeStyle = theme.tooltipBorder;\n ctx.lineWidth = 1;\n ctx.beginPath();\n ctx.rect(tx, ty, boxW, boxH);\n ctx.fill();\n ctx.stroke();\n ctx.globalAlpha = 1.0;\n\n ctx.fillStyle = theme.tooltipText;\n ctx.textBaseline = \"top\";\n for (let i = 0; i < rows.length; i++) {\n const row = rows[i];\n const rowY = ty + TOOLTIP_PADDING + i * TOOLTIP_ROW_HEIGHT;\n if (row.length <= 1) {\n ctx.textAlign = \"left\";\n ctx.fillText(row[0], tx + TOOLTIP_PADDING, rowY);\n continue;\n }\n\n let colX = tx + TOOLTIP_PADDING;\n for (let j = 0; j < row.length; j++) {\n const width = colWidths[j] ?? 0;\n if (colRightAlign[j]) {\n ctx.textAlign = \"right\";\n ctx.fillText(row[j], colX + width, rowY);\n } else {\n ctx.textAlign = \"left\";\n ctx.fillText(row[j], colX, rowY);\n }\n\n colX += width + TOOLTIP_COL_GAP;\n }\n }\n\n ctx.textAlign = \"left\";\n}\n\nexport function ellipsize(ctx: Context2D, text: string, maxW: number): string {\n if (ctx.measureText(text).width <= maxW) {\n return text;\n }\n\n let lo = 0;\n let hi = text.length;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (ctx.measureText(text.slice(0, mid) + \"\u2026\").width <= maxW) {\n lo = mid;\n } else {\n hi = mid - 1;\n }\n }\n\n return text.slice(0, lo) + \"\u2026\";\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { CssBounds, HostSink } from \"./tooltip-controller\";\nimport {\n DEFAULT_TOOLTIP_STYLE,\n NUMERIC_RE,\n TOOLTIP_COL_GAP,\n type TooltipContent,\n type TooltipStyle,\n} from \"./tooltip-grid\";\n\n/**\n * Host-side `HostSink` that materializes pinned tooltips as a `<div>`\n * next to the GL canvas, and applies cursor changes to the canvas's\n * own `style.cursor`. Host-only \u2014 depends on `document` /\n * `getComputedStyle`.\n */\nexport class DomHostSink implements HostSink {\n private _glCanvas: HTMLCanvasElement;\n private _parent: HTMLElement;\n private _div: HTMLDivElement | null = null;\n\n constructor(glCanvas: HTMLCanvasElement, parent: HTMLElement) {\n this._glCanvas = glCanvas;\n this._parent = parent;\n }\n\n pin(\n grid: TooltipContent,\n pos: { px: number; py: number },\n bounds: CssBounds,\n style: TooltipStyle = DEFAULT_TOOLTIP_STYLE,\n ): void {\n this.dismiss();\n const div = document.createElement(\"div\");\n\n div.className = \"webgl-tooltip\";\n div.style.maxHeight = `${Math.round(bounds.cssHeight * 0.6)}px`;\n renderTooltipGridDom(div, grid, style);\n\n if (getComputedStyle(this._parent).position === \"static\") {\n this._parent.style.position = \"relative\";\n }\n\n div.style.left = \"-9999px\";\n div.style.top = \"0px\";\n this._parent.appendChild(div);\n this._div = div;\n const divW = div.getBoundingClientRect().width;\n const divH = div.getBoundingClientRect().height;\n let tx = pos.px + 12;\n let ty = pos.py - divH - 8;\n if (tx + divW > bounds.cssWidth) {\n tx = pos.px - divW - 12;\n }\n\n if (tx < 0) {\n tx = 4;\n }\n\n if (ty < 0) {\n ty = pos.py + 12;\n }\n\n if (ty + divH > bounds.cssHeight) {\n ty = bounds.cssHeight - divH - 4;\n }\n\n div.style.left = `${tx}px`;\n div.style.top = `${ty}px`;\n }\n\n dismiss(): void {\n if (this._div) {\n this._div.remove();\n this._div = null;\n }\n }\n\n setCursor(cursor: string): void {\n this._glCanvas.style.cursor = cursor;\n }\n}\n\nfunction renderTooltipGridDom(\n root: HTMLDivElement,\n grid: TooltipContent,\n style: TooltipStyle,\n): void {\n const ncols = grid.reduce((n, row) => Math.max(n, row.length), 0);\n root.style.display = \"grid\";\n root.style.gridTemplateColumns = `repeat(${Math.max(1, ncols)}, minmax(0, max-content))`;\n root.style.columnGap = `${TOOLTIP_COL_GAP}px`;\n if (style.opacity < 1) {\n const pct = Math.max(0, Math.round(style.opacity * 100));\n root.style.background = `color-mix(in srgb, var(--psp-charts--tooltip--background) ${pct}%, transparent)`;\n }\n\n const rightAlign: boolean[] = [];\n for (const row of grid) {\n if (row.length <= 1) {\n continue;\n }\n\n for (let j = 1; j < row.length; j++) {\n if (row[j] === \"\") {\n continue;\n }\n\n const numeric = NUMERIC_RE.test(row[j]);\n rightAlign[j] =\n rightAlign[j] === undefined\n ? numeric\n : rightAlign[j] && numeric;\n }\n }\n\n for (const row of grid) {\n const span = row.length <= 1;\n for (let j = 0; j < Math.max(1, row.length); j++) {\n const cell = document.createElement(\"div\");\n cell.textContent = row[j] ?? \"\";\n cell.style.maxWidth = `${style.maxColumnPx * (span ? 2 : 1)}px`;\n cell.style.overflow = \"hidden\";\n cell.style.textOverflow = \"ellipsis\";\n cell.style.whiteSpace = \"nowrap\";\n if (span) {\n cell.style.gridColumn = \"1 / -1\";\n } else if (rightAlign[j]) {\n cell.style.textAlign = \"right\";\n }\n\n root.appendChild(cell);\n if (span) {\n break;\n }\n }\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\n/**\n * Renderer mode. `\"worker\"` runs the chart code in a Web Worker (off\n * the main thread, gets parallelism but pays a postMessage hop on\n * every interaction). `\"inprocess\"` dynamic-imports the same worker\n * module on the main thread so the bundle stays single-copy without\n * the worker boundary. The two paths share a `MessageChannel`-shaped\n * control protocol \u2014 only the handle around it differs.\n */\nexport const RUNTIME_MODE: \"worker\" | \"inprocess\" = \"worker\";\n\n/**\n * Build-time toggle between the two GL-canvas display strategies.\n *\n * - `\"direct\"` \u2014 host transfers `.webgl-canvas` to the renderer via\n * `transferControlToOffscreen`. The renderer's GL context renders\n * straight into the visible drawing buffer.\n *\n * - `\"blit\"` \u2014 host keeps the visible canvas main-thread with a 2D\n * context. The renderer creates its own internal `OffscreenCanvas`\n * for GL rendering and emits each completed frame as an\n * `ImageBitmap` over the control channel; the host blits the bitmap\n * into the visible canvas via `drawImage`.\n */\nexport const RENDER_BLIT_MODE: \"direct\" | \"blit\" = \"blit\";\n\n/**\n * Number of shared WebGL contexts in pooled blit mode.\n *\n * The browser caps live contexts per agent (~16 in Chromium) and\n * force-loses the oldest past that cap, so a page with more charts than\n * the cap cannot give each its own context. When `> 0` *and*\n * `RENDER_BLIT_MODE === \"blit\"`, every chart borrows one of this many\n * shared contexts (round-robin, sticky for the chart's lifetime) instead\n * of allocating its own \u2014 decoupling live-context count from chart\n * count. N charts render through K = this many contexts; the scheduler\n * serializes renders that land on the same context.\n *\n * `0` disables pooling (every chart gets its own context \u2014 the original\n * behavior). Pooling never applies to `\"direct\"` mode, which renders\n * into the host's transferred visible canvas and is permanently 1:1 with\n * a context; keep pages that need more than ~16 simultaneous charts on\n * `\"blit\"`.\n */\nexport const RENDER_CONTEXT_POOL_SIZE: number = 4;\n\n/**\n * Strict-mode validation for `BufferPool.upload`.\n */\nexport const BUFFER_POOL_STRICT: boolean = false;\n", "var $s=Object.defineProperty;var mm=(e,t,n)=>t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var G=(e,t)=>()=>(e&&(t=e(e=0)),t);var fm=(e,t)=>{for(var n in t)$s(e,n,{get:t[n],enumerable:!0})};var p=(e,t,n)=>mm(e,typeof t!=\"symbol\"?t+\"\":t,n);var ri,pr=G(()=>{ri=\"attribute vec2 a_start;attribute vec2 a_end;attribute float a_color_start;attribute float a_color_end;attribute float a_corner;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform vec2 u_color_range;uniform sampler2D u_gradient_lut;varying float v_edge_dist;varying vec3 v_color;float A(float B,float C,float D){if(D<=C){return 0.5;}else if(C<0.&&D>0.){float E=max(-C,D);return clamp(0.5+0.5*(B/E),0.,1.);}return clamp((B-C)/(D-C),0.,1.);}void main(){float C=u_color_range.x;float D=u_color_range.y;float F=0.5*(a_color_start+a_color_end);float G=A(F,C,D);v_color=texture2D(u_gradient_lut,vec2(G,0.5)).rgb;vec4 H=u_projection*vec4(a_start,0.,1.);vec4 I=u_projection*vec4(a_end,0.,1.);vec2 J=H.xy*u_resolution*0.5;vec2 K=I.xy*u_resolution*0.5;vec2 L=K-J;float M=length(L);L=M>0.001?L/M:vec2(1.,0.);vec2 N=vec2(-L.y,L.x);float O=step(1.5,a_corner);float P=1.-mod(a_corner,2.)*2.;vec4 Q=mix(H,I,O);float R=(u_line_width+1.5)*0.5;vec2 S=(N*P*R)/(u_resolution*0.5);gl_Position=Q+vec4(S,0.,0.);v_edge_dist=P;}\"});var si,br=G(()=>{si=\"precision highp float;uniform float u_line_width;varying float v_edge_dist;varying vec3 v_color;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(v_color,C);}\"});var li,gr=G(()=>{li=\"attribute vec2 a_position;attribute float a_color_value;attribute float a_size_value;uniform mat4 u_projection;uniform float u_point_size;uniform vec2 u_color_range;uniform vec2 u_size_range;uniform vec2 u_point_size_range;varying float v_color_t;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);float A=u_size_range.y-u_size_range.x;if(A>0.){float B=clamp((a_size_value-u_size_range.x)/A,0.,1.);gl_PointSize=mix(u_point_size_range.x,u_point_size_range.y,B);}else{gl_PointSize=u_point_size;}v_point_size=gl_PointSize;float C=u_color_range.x;float D=u_color_range.y;if(D<=C){v_color_t=0.5;}else if(C<0.&&D>0.){float E=max(-C,D);v_color_t=clamp(0.5+0.5*(a_color_value/E),0.,1.);}else{v_color_t=clamp((a_color_value-C)/(D-C),0.,1.);}}\"});var ai,hr=G(()=>{ai=\"precision highp float;varying float v_color_t;varying float v_point_size;uniform sampler2D u_gradient_lut;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5){discard;}float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);vec4 E=texture2D(u_gradient_lut,vec2(clamp(v_color_t,0.,1.),0.5));gl_FragColor=vec4(E.rgb,E.a*D);}\"});var Wt,xr=G(()=>{Wt=\"attribute vec2 a_corner;attribute vec2 a_position;attribute float a_color_value;uniform vec2 u_radius_ndc;uniform mat4 u_projection;uniform vec2 u_color_range;varying vec2 v_uv;varying float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}\"});var Ci,yr=G(()=>{Ci=\"precision highp float;uniform float u_intensity;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);float B=max(0.,1.-A);B=B*B*u_intensity;if(B<=0.){discard;}gl_FragColor=vec4(B,B*v_color_t,0.,0.);}\"});var vi,_r=G(()=>{vi=\"precision highp float;varying vec2 v_uv;varying float v_color_t;void main(){float A=length(v_uv);if(A>=1.){discard;}float B=(v_color_t-0.5)*2.;gl_FragColor=vec4(max(0.,B),max(0.,-B),0.,0.);}\"});var Zs,js=G(()=>{Zs=`#version 300 es\nin vec2 a_corner;in vec2 a_position;in float a_color_value;uniform mat4 u_projection;uniform vec2 u_radius_ndc;uniform vec2 u_color_range;out vec2 v_uv;out float v_color_t;void main(){vec4 A=u_projection*vec4(a_position,0.,1.);gl_Position=A+vec4(a_corner*u_radius_ndc*A.w,0.,0.);v_uv=a_corner;float B=u_color_range.x;float C=u_color_range.y;if(C<=B){v_color_t=0.5;}else if(B<0.&&C>0.){float D=max(-B,C);v_color_t=clamp(0.5+0.5*(a_color_value/D),0.,1.);}else{v_color_t=clamp((a_color_value-B)/(C-B),0.,1.);}}`});var Ks,qs=G(()=>{Ks=`#version 300 es\nprecision highp float;uniform float u_intensity;in vec2 v_uv;in float v_color_t;layout(location=0)out vec4 A;layout(location=1)out vec4 B;void main(){float C=length(v_uv);float D=max(0.0f,1.0f-C);D=D*D*u_intensity;if(D<=0.0f){discard;}A=vec4(D,D*v_color_t,0.0f,0.0f);float E=(v_color_t-0.5f)*2.0f;B=vec4(max(0.0f,E),max(0.0f,-E),0.0f,0.0f);}`});var Ai,Cr=G(()=>{Ai=\"attribute vec2 a_corner;varying vec2 v_uv;void main(){v_uv=a_corner*0.5+0.5;gl_Position=vec4(a_corner,0.,1.);}\"});var Li,vr=G(()=>{Li=\"precision highp float;uniform sampler2D u_heat;uniform sampler2D u_extreme;uniform sampler2D u_gradient_lut;uniform float u_heat_max;uniform int u_color_mode;varying vec2 v_uv;void main(){vec4 A=texture2D(u_heat,v_uv);float B=A.r;float C=A.g;if(B<=0.){discard;}float D;float E;float F=clamp(B/max(u_heat_max,1e-4),0.,1.);if(u_color_mode==0){D=pow(F,0.6);E=clamp(B,0.,1.);}else if(u_color_mode==2){vec4 G=texture2D(u_extreme,v_uv);float H=G.r;float I=G.g;float J=max(H,I);if(J<=0.){D=0.5;}else if(H>=I){D=clamp(0.5+H*0.5,0.5,1.);}else{D=clamp(0.5-I*0.5,0.,0.5);}E=F;}else if(u_color_mode==3){float K=C-0.5*B;float L=clamp(abs(K)/max(u_heat_max,1e-4),0.,1.);float M=K>=0.?1.:-1.;D=clamp(0.5+0.5*M*L,0.,1.);E=L;}else{D=clamp(C/B,0.,1.);E=F;}vec4 N=texture2D(u_gradient_lut,vec2(D,0.5));gl_FragColor=vec4(N.rgb,N.a*E);}\"});var Ti,Ar=G(()=>{Ti=\"attribute vec2 a_corner;uniform mat4 u_projection;uniform vec2 u_extent_min;uniform vec2 u_extent_max;uniform vec2 u_uv_min;uniform vec2 u_uv_max;varying vec2 v_uv;void main(){vec2 A=mix(u_extent_min,u_extent_max,a_corner);vec2 B=mix(u_uv_min,u_uv_max,vec2(a_corner.x,1.-a_corner.y));v_uv=B;gl_Position=u_projection*vec4(A,0.,1.);}\"});var wi,Lr=G(()=>{wi=\"precision highp float;varying vec2 v_uv;uniform sampler2D u_tile;uniform float u_alpha;void main(){vec4 A=texture2D(u_tile,v_uv);gl_FragColor=vec4(A.rgb,A.a*u_alpha);}\"});function Vm(e,t){if(t.width<=0||t.height<=0)return e;let n=e.xMax-e.xMin,i=e.yMax-e.yMin;if(n<=0||i<=0)return e;let o=t.width/t.height;if(n/i<o){let s=(e.xMin+e.xMax)/2,l=i*o/2;return{xMin:s-l,xMax:s+l,yMin:e.yMin,yMax:e.yMax}}else{let s=(e.yMin+e.yMax)/2,l=n/o/2;return{xMin:e.xMin,xMax:e.xMax,yMin:s-l,yMax:s+l}}}var kt,Ri=G(()=>{\"use strict\";kt=class{constructor(){p(this,\"he\",1);p(this,\"xe\",1);p(this,\"We\",0);p(this,\"ke\",0);p(this,\"Dt\",0);p(this,\"It\",1);p(this,\"Et\",0);p(this,\"Pt\",1);p(this,\"Qe\",null);p(this,\"ko\",!1);p(this,\"$i\",!1);p(this,\"ji\",!1);p(this,\"Bt\",null);p(this,\"Gt\",null);p(this,\"ui\",null);p(this,\"Zi\",!1);p(this,\"qi\",0);p(this,\"Ki\",0);p(this,\"tn\",null);p(this,\"nn\",null);p(this,\"on\",null);p(this,\"rn\",null)}get lockedAxis(){return this.Qe}get scaleX(){return this.he}get scaleY(){return this.xe}set scaleX(t){this.he=t}set scaleY(t){this.xe=t}get normTranslateX(){return this.We}get normTranslateY(){return this.ke}set normTranslateX(t){this.We=t}set normTranslateY(t){this.ke=t}get baseXRange(){return this.It-this.Dt}get baseYRange(){return this.Pt-this.Et}setBaseDomain(t,n,i,o){let r=n-t;if(this.isXDefault()||!this.$i)this.Dt=t,this.It=n;else{let l=this.It-this.Dt,a=(this.Dt+this.It)/2+this.We*l;this.Dt=t,this.It=n,this.We=r>0?(a-(t+n)/2)/r:0}let s=o-i;if(this.isYDefault()||!this.ji)this.Et=i,this.Pt=o;else{let l=this.Pt-this.Et,a=(this.Et+this.Pt)/2+this.ke*l;this.Et=i,this.Pt=o,this.ke=s>0?(a-(i+o)/2)/s:0}}pinAxis(t){t===\"x\"?this.$i=!0:this.ji=!0}unpinAxis(t){t===\"x\"?this.$i=!1:this.ji=!1}configure(t){this.Qe=t.lockAxis??null,this.ko=t.lockAspect??!1,this.Qe===\"x\"?(this.he=1,this.We=0):this.Qe===\"y\"&&(this.xe=1,this.ke=0)}isXDefault(){return this.he===1&&this.We===0}isYDefault(){return this.xe===1&&this.ke===0}isDefault(){return this.isXDefault()&&this.isYDefault()}getVisibleDomain(){let t=this.It-this.Dt,n=this.Pt-this.Et,i=t/this.he,o=n/this.xe,r=(this.Dt+this.It)/2+this.We*t,s=(this.Et+this.Pt)/2+this.ke*n,l={xMin:r-i/2,xMax:r+i/2,yMin:s-o/2,yMax:s+o/2};return this.ko&&this.Gt?Vm(l,this.Gt.e):l}attach(t,n,i){this.detach(),this.Bt=t,this.Gt=n,this.ui=i,this.tn=o=>{o.preventDefault();let r=t.getBoundingClientRect(),s=o.clientX-r.left,l=o.clientY-r.top,a=this.Gt.e;if(s<a.x||s>a.x+a.width||l<a.y||l>a.y+a.height)return;let u=(s-a.x)/a.width,m=(l-a.y)/a.height,f=this.he,c=this.xe,d=Math.pow(1.1,-o.deltaY/100);this.Qe!==\"x\"&&(this.he=Math.max(1,Math.min(1e5,this.he*d))),this.Qe!==\"y\"&&(this.xe=Math.max(1,Math.min(1e5,this.xe*d))),this.Qe!==\"x\"&&f!==this.he&&(this.We+=(u-.5)*(1/f-1/this.he)),this.Qe!==\"y\"&&c!==this.xe&&(this.ke+=(.5-m)*(1/c-1/this.xe)),this.ui()},this.nn=o=>{if(o.button!==0)return;let r=t.getBoundingClientRect(),s=o.clientX-r.left,l=o.clientY-r.top,a=this.Gt.e;s>=a.x&&s<=a.x+a.width&&l>=a.y&&l<=a.y+a.height&&(this.Zi=!0,this.qi=o.clientX,this.Ki=o.clientY,t.setPointerCapture(o.pointerId))},this.on=o=>{if(!this.Zi)return;let r=o.clientX-this.qi,s=o.clientY-this.Ki;this.qi=o.clientX,this.Ki=o.clientY;let l=this.Gt.e;this.Qe!==\"x\"&&l.width>0&&(this.We-=r/(l.width*this.he)),this.Qe!==\"y\"&&l.height>0&&(this.ke+=s/(l.height*this.xe)),this.ui()},this.rn=()=>{this.Zi=!1},t.addEventListener(\"wheel\",this.tn,{passive:!1}),t.addEventListener(\"pointerdown\",this.nn),t.addEventListener(\"pointermove\",this.on),t.addEventListener(\"pointerup\",this.rn)}updateLayout(t){this.Gt=t}detach(){this.Bt&&(this.tn&&this.Bt.removeEventListener(\"wheel\",this.tn),this.nn&&this.Bt.removeEventListener(\"pointerdown\",this.nn),this.on&&this.Bt.removeEventListener(\"pointermove\",this.on),this.rn&&this.Bt.removeEventListener(\"pointerup\",this.rn)),this.Bt=null,this.ui=null}reset(){this.he=1,this.xe=1,this.We=0,this.ke=0}serialize(){return{scaleX:this.he,scaleY:this.xe,normTranslateX:this.We,normTranslateY:this.ke}}restore(t){this.he=t.scaleX,this.xe=t.scaleY,this.We=t.normTranslateX,this.ke=t.normTranslateY}}});function ie(e){return{opacity:e.tooltip_opacity,maxColumnPx:e.tooltip_max_column_px}}function Fi(e,t,n){let i=n*2+wr,o=[],r=[],s=[],l=0;for(let m of t){if(m.length<=1){let c=nl(e,m[0]??\"\",i);s.push([c]),l=Math.max(l,e.measureText(c).width);continue}let f=[];for(let c=0;c<m.length;c++){let d=m[c]??\"\",b=nl(e,d,n);if(f.push(b),o[c]=Math.max(o[c]??0,e.measureText(b).width),c>=1&&d!==\"\"){let g=zm.test(d);r[c]=(r[c]===void 0||r[c])&&g}}s.push(f)}let a=0;for(let m=0;m<o.length;m++)a+=o[m]+(m>0?wr:0);let u=Math.max(l,a);return{rows:s,colWidths:o,colRightAlign:o.map((m,f)=>(r[f]??!1)&&f>=1),boxW:u+Cn*2,boxH:t.length*il+Cn*2-4}}function Si(e,t,n,i,o,r){let{rows:s,colWidths:l,colRightAlign:a,boxW:u,boxH:m}=t;e.globalAlpha=Math.min(1,Math.max(0,r)),e.fillStyle=o.mi,e.strokeStyle=o.No,e.lineWidth=1,e.beginPath(),e.rect(n,i,u,m),e.fill(),e.stroke(),e.globalAlpha=1,e.fillStyle=o.Oo,e.textBaseline=\"top\";for(let f=0;f<s.length;f++){let c=s[f],d=i+Cn+f*il;if(c.length<=1){e.textAlign=\"left\",e.fillText(c[0],n+Cn,d);continue}let b=n+Cn;for(let g=0;g<c.length;g++){let h=l[g]??0;a[g]?(e.textAlign=\"right\",e.fillText(c[g],b+h,d)):(e.textAlign=\"left\",e.fillText(c[g],b,d)),b+=h+wr}}e.textAlign=\"left\"}function nl(e,t,n){if(e.measureText(t).width<=n)return t;let i=0,o=t.length;for(;i<o;){let r=i+o+1>>1;e.measureText(t.slice(0,r)+\"\\u2026\").width<=n?i=r:o=r-1}return t.slice(0,i)+\"\\u2026\"}var Qe,zm,il,Cn,wr,be=G(()=>{\"use strict\";Qe={opacity:1,maxColumnPx:160};zm=/^[-+\u2212]?[$\u20AC\u00A3\u00A5]?\\s?\\d[\\d.,\u00A0\u202F\\s]*(?:[eE][-+]?\\d+|[KMB%])?$/,il=16,Cn=8,wr=8});function rl(e){return e&&!(\"format\"in e)?e:void 0}function $m(e,t){let n={};for(let[o,r]of Object.entries(t??{}))r!=null&&(n[o]=r);let i={...e};return(\"minimumFractionDigits\"in n||\"maximumFractionDigits\"in n)&&(delete i.minimumFractionDigits,delete i.maximumFractionDigits),(\"minimumSignificantDigits\"in n||\"maximumSignificantDigits\"in n)&&(delete i.minimumSignificantDigits,delete i.maximumSignificantDigits),Object.assign(i,n)}function Mr(e,t,n){let i=n??Ym[e]??{},o=t?$m(i,t):i;return new Intl.NumberFormat(navigator.languages,o)}function Rr(e,t){if(e=e??t,!e||!(\"format\"in e)){let i=rl(e),o={timeZone:i?.timeZone??void 0,dateStyle:i?.dateStyle===\"disabled\"?void 0:i?.dateStyle??ol.dateStyle,timeStyle:i?.timeStyle===\"disabled\"?void 0:i?.timeStyle??ol.timeStyle};return new Intl.DateTimeFormat(navigator.languages,o)}let n={timeZone:e.timeZone??void 0,hour12:e.hour12??!0,fractionalSecondDigits:e.fractionalSecondDigits};return e.year!==\"disabled\"&&(n.year=e.year??\"2-digit\"),e.month!==\"disabled\"&&(n.month=e.month??\"numeric\"),e.day!==\"disabled\"&&(n.day=e.day??\"numeric\"),e.weekday&&e.weekday!==\"disabled\"&&(n.weekday=e.weekday),e.hour!==\"disabled\"&&(n.hour=e.hour??\"numeric\"),e.minute!==\"disabled\"&&(n.minute=e.minute??\"numeric\"),e.second!==\"disabled\"&&(n.second=e.second??\"numeric\"),new Intl.DateTimeFormat(navigator.languages,n)}function sl(e,t){let n=rl(e??t),i={timeZone:\"utc\",dateStyle:n?.dateStyle===\"disabled\"?void 0:n?.dateStyle??Xm.dateStyle};return new Intl.DateTimeFormat(navigator.languages,i)}function Fr(e){return e.split(\"|\").at(-1)??e}var Ym,ol,Xm,ll=G(()=>{\"use strict\";Ym={float:{style:\"decimal\",minimumFractionDigits:2,maximumFractionDigits:2}},ol={dateStyle:\"short\",timeStyle:\"medium\"},Xm={dateStyle:\"short\"}});var Ii,al=G(()=>{\"use strict\";Ii=class{constructor(t,n=128){p(this,\"ln\");p(this,\"g\",new Map);p(this,\"Re\",new Map);p(this,\"Uo\");this.ln=t,this.Uo=n}async fetchRow(t){if(!this.ln)throw new Error(\"LazyRowFetcher disposed\");let n=this.g.get(t);if(n)return this.g.delete(t),this.g.set(t,n),n;let i=this.Re.get(t);if(i)return i;let o=this.Tr(t);this.Re.set(t,o);try{let r=await o;if(!this.ln)return r;if(this.g.set(t,r),this.g.size>this.Uo){let s=this.g.keys().next().value;s!==void 0&&this.g.delete(s)}return r}finally{this.Re.delete(t)}}async Tr(t){let n=this.ln;if(!n)throw new Error(\"LazyRowFetcher disposed\");let i=new Map;return await n.with_typed_arrays({start_row:t,end_row:t+1,float32:!0},(o,r,s,l)=>{for(let a=0;a<o.length;a++){let u=o[a];if(u.startsWith(\"__\"))continue;let m=r[a],f=s[a],c=l[a];(f?!(f[0]>>0&1):!1)?i.set(u,null):c?i.set(u,c[m[0]]):i.set(u,m[0])}}),i}dispose(){this.ln=null,this.g.clear(),this.Re.clear()}get isDisposed(){return this.ln===null}}});var Sr,Dr,ul,ml=G(()=>{\"use strict\";Sr={notation:\"compact\",compactDisplay:\"short\",minimumFractionDigits:0,maximumFractionDigits:1},Dr={dateStyle:\"medium\",timeStyle:\"disabled\"},ul={dateStyle:\"medium\"}});var cl,fl=G(()=>{cl=[{id:\"osm\",label:\"OpenStreetMap\",template:\"https://tile.openstreetmap.org/{z}/{x}/{y}.png\",attribution:\"\\xA9 OpenStreetMap contributors\",tile_size:256,max_zoom:19},{id:\"versatiles-satellite\",label:\"Satellite (VersaTiles)\",template:\"https://tiles.versatiles.org/tiles/satellite/{z}/{x}/{y}\",attribution:\"\\xA9 VersaTiles (versatiles.org/sources)\",tile_size:256,max_zoom:12}]});function dl(e){if(typeof e!=\"object\"||e===null)throw new TypeError(\"TileSourceSpec must be an object\");let t=e,n=m=>{let f=t[m];if(typeof f!=\"string\"||f.length===0)throw new TypeError(`TileSourceSpec.${m} must be a non-empty string`);return f},i=n(\"id\"),o=n(\"label\"),r=n(\"template\"),s=n(\"attribution\");for(let m of[\"{z}\",\"{x}\",\"{y}\"])if(!r.includes(m))throw new TypeError(`TileSourceSpec.template must contain \"${m}\"`);let l=t.subdomains??[];if(!Array.isArray(l)||l.some(m=>typeof m!=\"string\"||m.length===0))throw new TypeError(\"TileSourceSpec.subdomains must be an array of non-empty strings\");let a=Object.freeze([...l]);if(r.includes(\"{s}\")&&a.length===0)throw new TypeError('TileSourceSpec.template uses \"{s}\" but no subdomains were given');let u=(m,f)=>{let c=t[m];if(c===void 0)return f;if(typeof c!=\"number\"||!Number.isFinite(c)||c<=0)throw new TypeError(`TileSourceSpec.${m} must be a positive number`);return c};return Object.freeze({id:i,label:o,template:r,subdomains:a,attribution:s,tile_size:u(\"tile_size\",256),max_zoom:u(\"max_zoom\",19)})}function Zm(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(16)}var Ir,Er,et,Ei=G(()=>{\"use strict\";fl();Ir=class{constructor(t,n,i,o=256,r=19,s=[]){this.id=t;this.template=n;this.attribution=i;this.tileSize=o;this.maxZoom=r;this.subdomains=s}urlFor(t,n,i){let o=this.template.replace(\"{z}\",String(t)).replace(\"{x}\",String(n)).replace(\"{y}\",String(i));if(this.subdomains.length>0){let r=(n+i)%this.subdomains.length;o=o.replace(\"{s}\",this.subdomains[r])}return o}};Er=class{constructor(t){p(this,\"an\",new Map);for(let n of t){let i=dl(n);this.an.set(i.id,i)}}register(t){let n=dl(t);return this.an.set(n.id,n),n}list(){return[...this.an.values()]}specFor(t){return this.an.get(t)}sourceFor(t){let n=this.an.get(t)??this.an.values().next().value,i=Zm(`${n.template}\\0${n.subdomains.join(\",\")}`);return new Ir(`${n.id}@${i}`,n.template,n.attribution,n.tile_size,n.max_zoom,n.subdomains)}},et=new Er(cl)});var pl,Ue,Pr=G(()=>{\"use strict\";Ei();pl={facet_mode:\"grid\",shared_x_axis:!0,shared_y_axis:!0,coordinated_tooltip:!1,zoom_mode:\"shared\",facet_padding:6},Ue={auto_alt_y_axis:!1,facet_mode:\"grid\",facet_zoom_mode:\"shared\",series_zoom_mode:\"dynamic\",include_zero:!1,domain_mode:\"expand\",line_width_px:2,point_size_px:8,band_inner_frac:.5,bar_inner_pad:.1,wick_width_px:1,ohlc_line_width_px:1,gradient_radius_px:32,gradient_intensity:.6,gradient_heat_max:4,gradient_color_mode:\"mean\",map_tile_provider:et.list()[0].id,map_tile_alpha:1,numeric_axes:!0,legend_mode:\"auto\",legend_size_mode:\"auto\",legend_width_px:0,legend_height_px:160,legend_anchor:\"top-right\",legend_x:0,legend_y:0,legend_opacity:.8,tooltip_max_column_px:160,tooltip_opacity:.8}});function He(e,t,n,i,o,r,s={}){if(!e)return;let l=e.getContext(\"2d\");if(!l)return;l.save(),l.setTransform(1,0,0,1,0,0),l.scale(r,r),l.font=`11px ${o.fontFamily}`;let a=Fi(l,n,s.maxColumnPx??Qe.maxColumnPx),{boxW:u,boxH:m}=a,f=t.px+12,c=t.py-m-8;f+u>i.cssWidth&&(f=t.px-u-12),c<0&&(c=t.py+12),c+m>i.cssHeight&&(c=i.cssHeight-m-4),s.crosshair&&(l.strokeStyle=o.Ct,l.globalAlpha=.3,l.lineWidth=1,l.setLineDash([4,4]),l.beginPath(),l.moveTo(t.px,i.e.y),l.lineTo(t.px,i.e.y+i.e.height),l.moveTo(i.e.x,t.py),l.lineTo(i.e.x+i.e.width,t.py),l.stroke(),l.setLineDash([]),l.globalAlpha=1),s.highlightRadius&&s.highlightRadius>0&&(l.strokeStyle=o.Ct,l.globalAlpha=.8,l.lineWidth=2,l.beginPath(),l.arc(t.px,t.py,s.highlightRadius,0,Math.PI*2),l.stroke(),l.globalAlpha=1),n.length>0&&Si(l,a,f,c,o,s.opacity??Qe.opacity),l.restore()}var Pi,Nt=G(()=>{\"use strict\";be();Pi=class{constructor(){p(this,\"Xe\",null);p(this,\"un\",0);p(this,\"mn\",null);p(this,\"Mn\",null);p(this,\"_t\",!1)}get isPinned(){return this._t}setHost(t){this._t&&(this.Mn?.dismiss(),this._t=!1),this.Mn=t}setCursor(t){this.Mn?.setCursor(t)}attach(t){this.detach(),this.Xe=t}detach(){this.un&&(cancelAnimationFrame(this.un),this.un=0),this.mn!==null&&(clearTimeout(this.mn),this.mn=null),this.Xe=null}dispatchHover(t,n){if(this._t||!this.Xe||this.un||this.mn!==null)return;let i=()=>{this.un=0,this.mn=null,this.Xe?.onHover(t,n)};typeof requestAnimationFrame==\"function\"?this.un=requestAnimationFrame(i):this.mn=setTimeout(i,16)}dispatchLeave(){this._t||!this.Xe||this.Xe.onLeave()}dispatchClick(t,n){if(this.Xe&&!this.Xe.onClickPre?.(t,n)){if(this._t){let i=this.Xe;this.dismiss(),i.onUnpin?.();return}this.Xe.onPin?.(t,n)}}dispatchDblClick(t,n){this.Xe?.onDblClick?.(t,n)}pin(t,n,i,o=Qe){t.length!==0&&(this.Mn?.pin(t,n,i,o),this._t=!0)}dismiss(){this.Mn?.dismiss(),this._t=!1}}});function _e(e,t,n){return Math.min(n,Math.max(t,e))}function Br(e){return Number.isFinite(e)?_e(e,0,1):0}function gl(e,t){if(t<=0)return 0;let n=Math.round(e);return n<=0?0:n>=Math.round(t)?1:Br(n/t)}function hl(e){return e===\"top-right\"||e===\"bottom-right\"}function xl(e){return e===\"bottom-left\"||e===\"bottom-right\"}function we(e,t){return e.legend_width_px>0?_e(e.legend_width_px,yt,Gi):t}function se(e,t){return e.legend_mode!==\"auto\"?e.legend_mode:t<=tf?\"floating\":\"sidebar\"}function nt(e,t,n=80,i=0){return!t||se(e,i)!==\"sidebar\"?16:we(e,n)}function Ni(e,t,n,i=0){return!t||se(e,i)!==\"sidebar\"?0:we(e,n)}function Ot(e){return Math.round(e*1e4)/1e4}var yt,Gi,Bi,qm,Km,tt,vn,yl,Gr,ki,Wr,_l,Jm,xt,bl,Qm,ef,tf,nf,Wi,Ve=G(()=>{\"use strict\";Pr();yt=48,Gi=512,Bi=48,qm=160,Km=160,tt=18,vn=18,yl=8,Gr=12,ki=8,Wr=16,_l=16,Jm=10,xt=5,bl=12,Qm=10,ef=3;tf=7;nf=[\"legend_mode\",\"legend_size_mode\",\"legend_width_px\",\"legend_height_px\",\"legend_anchor\",\"legend_x\",\"legend_y\",\"legend_opacity\"],Wi=class e{constructor(){p(this,\"ye\",null);p(this,\"Wt\",0);p(this,\"$e\",null);p(this,\"fn\",!1);p(this,\"Ji\",!1);p(this,\"Ho\",\"\")}clampScroll(t,n){return this.Wt=_e(this.Wt,0,Math.max(0,n-t)),this.Wt}setPainted(t){this.ye=t}clearPainted(){this.ye=null}floatingBox(t,n,i,o){let r=t.legend_size_mode!==\"fixed\",s=r?o?.boxWidth?.()??0:0,l=r?o?.entryCount??0:0,a=s>0?s:t.legend_width_px>0&&!r?t.legend_width_px:qm,u=l>0?tt+ki+l*vn:t.legend_height_px>0&&!r?t.legend_height_px:Km,m=_e(u,Bi,Math.max(Bi,i-8)),f=m<u,c=_e(a+(f&&s>0?Jm:0),yt,Math.max(yt,Math.floor(n/2))),d=Math.max(0,n-c),b=Math.max(0,i-m),g=Br(t.legend_x)*d,h=Br(t.legend_y)*b;return{x:Math.round(hl(t.legend_anchor)?d-g:g),y:Math.round(xl(t.legend_anchor)?b-h:h),width:c,height:m}}reconcileConfig(t,n){if(this.$e){for(let i of nf)if(t[i]!==n[i]){this.$e=null;return}}}cancelGesture(){this.$e=null,this.fn=!1}handleEvent(t,n){switch(t.type){case\"wheel\":return this.tn(t.mx,t.my,t.deltaY,n);case\"pointerdown\":return this.nn(t.mx,t.my,n);case\"pointermove\":return this.on(t.mx,t.my,n);case\"pointerup\":return this.rn(n);case\"click\":return this.wr(t.mx,t.my,n);case\"dblclick\":return this.Mr(t.mx,t.my,n);case\"pointerleave\":return this.Ji=!1,this.fi(\"\",n),!1}}hitTest(t,n){let i=this.ye;if(!i)return\"none\";let o=i.box;if(i.mode===\"floating\"){let s=t>=o.x-xt&&t<=o.x+o.width+xt,l=n>=o.y-xt&&n<=o.y+o.height+xt;if(!s||!l)return\"none\";let a=Math.abs(t-o.x)<=xt,u=Math.abs(t-(o.x+o.width))<=xt,m=Math.abs(n-(o.y+o.height))<=xt;return u&&n>=o.y+o.height-bl||m&&t>=o.x+o.width-bl?\"resize-se\":u?\"resize-e\":a?\"resize-w\":m?\"resize-s\":this.Vo(t,n)?\"scrollbar\":n<=o.y+tt?\"move\":\"body\"}let r=n>=o.y&&n<=o.y+o.height;return r&&t>=o.x-14&&t<=o.x+2?\"resize-w\":r&&t>=o.x&&t<=o.x+o.width?this.Vo(t,n)?\"scrollbar\":\"body\":\"none\"}zo(){let t=this.ye;return!!t&&t.contentHeight>t.content.height+.5}Vo(t,n){let i=this.ye;if(!i||!this.zo())return!1;let o=i.content;return t>=o.x+o.width-Qm&&t<=o.x+o.width&&n>=o.y&&n<=o.y+o.height}tn(t,n,i,o){return this.$e?!0:this.hitTest(t,n)===\"none\"?!1:(this.zo()&&this.Yo(this.Wt+i,o),!0)}nn(t,n,i){let o=this.hitTest(t,n);if(o===\"none\")return!1;let r=this.ye;if(this.fn=!1,o===\"scrollbar\")return this.$e={kind:\"scrollbar\",startMy:n,startScroll:this.Wt},!0;let s={legend_size_mode:i.cfg.legend_size_mode,legend_width_px:i.cfg.legend_width_px,legend_height_px:i.cfg.legend_height_px,legend_x:i.cfg.legend_x,legend_y:i.cfg.legend_y};return o===\"resize-w\"||o===\"resize-e\"||o===\"resize-s\"||o===\"resize-se\"?(this.$e={kind:o,startMx:t,startMy:n,startBox:{...r.box},startGutter:r.sidebarGutter??r.box.width,snapshot:s},this.fi(o===\"resize-s\"?\"ns-resize\":o===\"resize-se\"?\"nwse-resize\":\"ew-resize\",i),!0):(r.mode===\"floating\"&&(this.$e={kind:\"move\",startMx:t,startMy:n,startBox:{...r.box},moved:!1,snapshot:s}),!0)}on(t,n,i){if(this.$e)return this.Rr(t,n,i),!0;let o=this.hitTest(t,n),r=o!==\"none\";return r&&!this.Ji&&i.dispatchLeave(),this.Ji=r,this.fi(e.Fr(o),i),r&&this.ye.mode===\"floating\"}rn(t){let n=this.$e;if(!n)return!1;if(this.$e=null,n.kind===\"scrollbar\")return this.fn=!0,!0;if(n.kind===\"move\"&&!n.moved)return!0;this.fn=!0;let i={},o=t.cfg;return o.legend_size_mode!==n.snapshot.legend_size_mode&&(i.legend_size_mode=o.legend_size_mode),o.legend_width_px!==n.snapshot.legend_width_px&&(i.legend_width_px=Math.round(o.legend_width_px)),o.legend_height_px!==n.snapshot.legend_height_px&&(i.legend_height_px=Math.round(o.legend_height_px)),Ot(o.legend_x)!==Ot(n.snapshot.legend_x)&&(i.legend_x=Ot(o.legend_x)),Ot(o.legend_y)!==Ot(n.snapshot.legend_y)&&(i.legend_y=Ot(o.legend_y)),Object.keys(i).length>0&&t.postDelta(i),!0}Mr(t,n,i){let o=this.hitTest(t,n);if(o===\"none\")return!1;let r=o===\"resize-w\"||o===\"resize-e\"||o===\"resize-se\",s=o===\"resize-s\"||o===\"resize-se\";if(!r&&!s)return this.ye.mode===\"floating\";let l=i.cfg,a={};return this.ye.mode===\"floating\"&&l.legend_size_mode!==Ue.legend_size_mode&&(l.legend_size_mode=Ue.legend_size_mode,a.legend_size_mode=l.legend_size_mode),r&&l.legend_width_px!==Ue.legend_width_px&&(l.legend_width_px=Ue.legend_width_px,a.legend_width_px=l.legend_width_px),s&&l.legend_height_px!==Ue.legend_height_px&&(l.legend_height_px=Ue.legend_height_px,a.legend_height_px=l.legend_height_px),Object.keys(a).length>0&&(i.repaint(this.ye.mode===\"sidebar\"),i.postDelta(a)),!0}wr(t,n,i){if(this.fn)return this.fn=!1,!0;let o=this.hitTest(t,n);if(o===\"none\")return!1;if(o===\"scrollbar\")return!0;if(this.ye.mode===\"floating\"){for(let r of i.legendRects){let s=r.rect;if(t>=s.x&&t<=s.x+s.width&&n>=s.y&&n<=s.y+s.height)return!1}return!0}return!1}Rr(t,n,i){let o=this.$e,r=i.cfg,{cssWidth:s,cssHeight:l}=i,a=Math.max(yt,Math.floor(s/2));switch(o.kind){case\"scrollbar\":{let u=this.ye;if(!u||u.content.height<=0)return;let m=u.contentHeight/u.content.height;this.Yo(o.startScroll+(n-o.startMy)*m,i);return}case\"move\":{if(!o.moved){if(Math.hypot(t-o.startMx,n-o.startMy)<ef)return;o.moved=!0,this.fi(\"grabbing\",i)}let u=o.startBox.width,m=o.startBox.height,f=_e(o.startBox.x+(t-o.startMx),0,Math.max(0,s-u)),c=_e(o.startBox.y+(n-o.startMy),0,Math.max(0,l-m));this.ci(i,f,c,u,m),i.repaint(!1);return}case\"resize-w\":{if(this.ye?.mode===\"sidebar\"){r.legend_width_px=_e(Math.round(o.startGutter+(o.startMx-t)),yt,Math.min(Gi,a)),i.repaint(!0);return}this.Qi(i,o.startBox);let u=o.startBox.x+o.startBox.width,m=_e(Math.round(o.startBox.width+(o.startMx-t)),yt,Math.min(Gi,a));r.legend_width_px=m,this.ci(i,u-m,o.startBox.y,m,o.startBox.height),i.repaint(!1);return}case\"resize-e\":case\"resize-se\":{this.Qi(i,o.startBox);let u=_e(Math.round(o.startBox.width+(t-o.startMx)),yt,Math.min(Gi,a));r.legend_width_px=u;let m=o.kind===\"resize-se\"?this.Xo(o.startBox,o.startMy,n,i):o.startBox.height;this.ci(i,o.startBox.x,o.startBox.y,u,m),i.repaint(!1);return}case\"resize-s\":{this.Qi(i,o.startBox);let u=this.Xo(o.startBox,o.startMy,n,i);this.ci(i,o.startBox.x,o.startBox.y,o.startBox.width,u),i.repaint(!1);return}}}Qi(t,n){t.cfg.legend_size_mode!==\"fixed\"&&(t.cfg.legend_size_mode=\"fixed\",t.cfg.legend_width_px=Math.round(n.width),t.cfg.legend_height_px=Math.round(n.height))}Xo(t,n,i,o){let r=_e(Math.round(t.height+(i-n)),Bi,Math.max(Bi,o.cssHeight-8));return o.cfg.legend_height_px=r,r}ci(t,n,i,o,r){let s=Math.max(0,t.cssWidth-o),l=Math.max(0,t.cssHeight-r),a=t.cfg.legend_anchor;t.cfg.legend_x=gl(hl(a)?s-n:n,s),t.cfg.legend_y=gl(xl(a)?l-i:i,l)}Yo(t,n){let i=this.ye;if(!i)return;let o=_e(t,0,Math.max(0,i.contentHeight-i.content.height));o!==this.Wt&&(this.Wt=o,n.repaint(!1))}static Fr(t){switch(t){case\"resize-w\":case\"resize-e\":return\"ew-resize\";case\"resize-s\":return\"ns-resize\";case\"resize-se\":return\"nwse-resize\";case\"move\":return\"grab\";default:return\"\"}}fi(t,n){t!==this.Ho&&(this.Ho=t,n.setCursor(t))}}});function Oi(e){let t=e.trim();if(t.startsWith(\"#\")){let i=t.slice(1);return i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]),[parseInt(i.slice(0,2),16)/255,parseInt(i.slice(2,4),16)/255,parseInt(i.slice(4,6),16)/255]}let n=t.match(/rgba?\\(\\s*(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)/);return n?[+n[1]/255,+n[2]/255,+n[3]/255]:[.5,.5,.5]}var kr=G(()=>{\"use strict\"});function Cl(e){if(!e)return _t.slice();let t=e.trim();if(!t)return _t.slice();let n=t.indexOf(\"(\");if(n<0||!/^linear-gradient\\s*\\(/i.test(t))return _t.slice();let i=t.lastIndexOf(\")\");if(i<=n)return _t.slice();let o=t.substring(n+1,i),r=[],s=0,l=0;for(let c=0;c<o.length;c++){let d=o[c];d===\"(\"?s++:d===\")\"?s--:d===\",\"&&s===0&&(r.push(o.substring(l,c)),l=c+1)}r.push(o.substring(l));let a=[],u=0;if(r.length>0){let c=r[0].trim().toLowerCase();(c.startsWith(\"to \")||/^[-\\d.]+(deg|rad|grad|turn)/.test(c))&&(u=1)}for(let c=u;c<r.length;c++){let d=r[c].trim();if(!d)continue;let b=d.match(/\\s([\\-\\d.]+)%\\s*$/),g=b?d.substring(0,b.index).trim():d,h=b?parseFloat(b[1])/100:null;try{let x=Oi(g);a.push({color:x,offset:h})}catch{}}if(a.length===0)return _t.slice();if(a.length===1){let[c,d,b]=a[0].color;return[{offset:0,color:[c,d,b,1]},{offset:1,color:[c,d,b,1]}]}a[0].offset===null&&(a[0].offset=0),a[a.length-1].offset===null&&(a[a.length-1].offset=1);for(let c=1;c<a.length-1;c++){if(a[c].offset!==null)continue;let d=c+1;for(;d<a.length&&a[d].offset===null;)d++;let b=a[c-1].offset,g=a[d].offset,h=d-(c-1);for(let x=c;x<d;x++)a[x].offset=b+(x-(c-1))/h*(g-b);c=d-1}let m=0;return a.map(c=>{let d=Math.max(m,Math.min(1,c.offset));return m=d,{offset:d,color:[c.color[0],c.color[1],c.color[2],1]}})}function Nr(e){let t=e.trim();if(t.startsWith(\"#\")){let a=t.slice(1);return/^[0-9a-f]+$/i.test(a)?a.length===3||a.length===4?[parseInt(a[0]+a[0],16)/255,parseInt(a[1]+a[1],16)/255,parseInt(a[2]+a[2],16)/255]:a.length===6||a.length===8?[parseInt(a.slice(0,2),16)/255,parseInt(a.slice(2,4),16)/255,parseInt(a.slice(4,6),16)/255]:null:null}let n=t.match(/^rgba?\\(([^)]*)\\)$/i);if(!n)return null;let i=n[1].split(\"/\")[0].split(/[\\s,]+/).filter(a=>a.length>0);if(i.length<3||i.length>4)return null;let o=a=>{let u=a.endsWith(\"%\"),m=parseFloat(u?a.slice(0,-1):a);if(!isFinite(m))return null;let f=u?m/100*255:m;return Math.max(0,Math.min(255,Math.round(f)))/255},r=o(i[0]),s=o(i[1]),l=o(i[2]);return r===null||s===null||l===null?null:[r,s,l]}function vl(e){let t=e.trim().match(/^linear-gradient\\s*\\((.*)\\)$/is);if(!t)return null;let n=t[1],i=[],o=0,r=0;for(let l=0;l<n.length;l++){let a=n[l];a===\"(\"?o++:a===\")\"?o--:a===\",\"&&o===0&&(i.push(n.substring(r,l)),r=l+1)}i.push(n.substring(r));let s=[];for(let l=0;l<i.length;l++){let a=i[l].trim();if(!a)return null;let u=a.toLowerCase();if(l===0&&(u.startsWith(\"to \")||/^[-\\d.]+(deg|rad|grad|turn)$/.test(u)))continue;let m=a.match(/\\s([^\\s)]+)$/),f=a,c=null;if(m){let b=m[1];if(b.endsWith(\"%\")){let g=parseFloat(b.slice(0,-1));if(!isFinite(g))return null;f=a.substring(0,m.index).trim(),c=g/100}else if(/^[-\\d.]/.test(b))return null}let d=Nr(f);if(!d)return null;s.push([d,c])}return s}function Al(e){let t=vl(e);if(!t||t.length<2)return null;let n=t.map(([,r])=>r),i=n.length-1;n[0]===null&&(n[0]=0),n[i]===null&&(n[i]=1);for(let r=1;r<i;r++){if(n[r]!==null)continue;let s=r+1;for(;n[s]===null;)s++;let l=n[r-1],a=n[s],u=s-(r-1);for(let m=r;m<s;m++)n[m]=l+(m-(r-1))/u*(a-l);r=s-1}let o=t.map(([r],s)=>({offset:Math.max(0,Math.min(1,n[s])),color:[r[0],r[1],r[2],1]}));return o.sort((r,s)=>r.offset-s.offset),o}function Ui(e){let t=vl(e);if(!t||t.length===0)return null;let n=[];for(let[i,o]of t){if(o!==null)return null;n.push(i)}return n}function Se(e,t){if(e.length===0)return[0,0,0,1];if(t<=e[0].offset)return e[0].color.slice();let n=e[e.length-1];if(t>=n.offset)return n.color.slice();let i=0,o=e.length-1;for(;o-i>1;){let u=i+o>>1;e[u].offset<=t?i=u:o=u}let r=e[i],s=e[o],l=s.offset-r.offset,a=l>0?(t-r.offset)/l:0;return[r.color[0]+(s.color[0]-r.color[0])*a,r.color[1]+(s.color[1]-r.color[1])*a,r.color[2]+(s.color[2]-r.color[2])*a,r.color[3]+(s.color[3]-r.color[3])*a]}function Ct(e,t,n){if(!isFinite(e)||t===n)return .5;let i;if(t>=0?i=n:n<=0?i=-t:i=Math.max(-t,n),i<=0)return .5;let o=.5+.5*(e/i);return o<0?0:o>1?1:o}function Hi(e,t){if(!isFinite(e)||!isFinite(t)||e>=t)return[0,0];let n;return e>=0?n=t:t<=0?n=-e:n=Math.max(-e,t),n<=0?[0,0]:[-n,n]}function Ll(e){if(e.length===0)return _t.slice();if(e.length===1){let[n,i,o]=e[0];return[{offset:0,color:[n,i,o,1]},{offset:1,color:[n,i,o,1]}]}let t=e.length-1;return e.map(([n,i,o],r)=>({offset:r/t,color:[n,i,o,1]}))}function Tl(e,t=256){let n=new Uint8Array(t*4);for(let i=0;i<t;i++){let o=t===1?0:i/(t-1),r=Se(e,o);n[i*4]=Math.round(r[0]*255),n[i*4+1]=Math.round(r[1]*255),n[i*4+2]=Math.round(r[2]*255),n[i*4+3]=Math.round(r[3]*255)}return n}var _t,ge=G(()=>{\"use strict\";kr();_t=[{offset:0,color:[3/255,102/255,214/255,1]},{offset:1,color:[255/255,127/255,14/255,1]}]});function of(e){return isFinite(e)?e<0?0:e>1?1:e:.5}function wl(e){return!isFinite(e)||e<0?1:e}function Ml(e){let t=(r,s)=>e[r]||s,n=e[\"--psp-charts--gradient--background\"]||e[\"--psp-charts--full-gradient--background\"]||\"linear-gradient(#0366d6 0%, #ff7f0e 100%)\",i=Cl(n),o=[];for(let r=1;;r++){let s=e[`--psp-charts--series-${r}--color`];if(!s)break;o.push(Oi(s))}return{fontFamily:t(\"--psp-charts--font-family\",t(\"font-family\",\"monospace\")),backgroundColor:t(\"--psp--background-color\",\"rgba(255, 255, 255, 1)\"),Ct:t(\"--psp-charts--axis-ticks--color\",\"rgba(160, 0, 0, 0.8)\"),Fe:t(\"--psp--color\",\"rgba(180, 0, 0, 0.9)\"),di:t(\"--psp-charts--axis-lines--color\",\"rgba(160, 0, 0, 0.4)\"),Rn:t(\"--psp-charts--gridline--color\",\"rgba(255, 0, 0, 1)\"),N:i,cn:t(\"--psp-charts--legend--color\",\"rgba(180, 180, 180, 0.9)\"),eo:t(\"--psp-charts--legend-border--color\",\"rgba(128,128,128,0.3)\"),mi:t(\"--psp-charts--tooltip--background\",\"rgba(155,155,155,0.8)\"),Oo:t(\"--psp-charts--tooltip--color\",\"#161616\"),No:t(\"--psp-charts--tooltip--border-color\",\"#fff\"),pi:of(parseFloat(t(\"--psp-charts--area--opacity\",\"0.85\"))),$o:wl(parseFloat(t(\"--psp-charts--heatmap-gap--px\",\"0\"))),jo:wl(parseFloat(t(\"--psp-charts--sunburst-gap--px\",\"1\"))),Ne:o}}var Rl=G(()=>{\"use strict\";kr();ge()});function Fl(e,t,n){if(!n)return e;let i=t?.[n];if(!i)return e;let o=e,r=sf(i.gradient);r&&(o={...o,N:r});let s=rf(i.palette);return s&&(o={...o,Ne:s}),o}function rf(e){return typeof e!=\"string\"?null:Ui(e)}function sf(e){return typeof e!=\"string\"?null:Al(e)}var Sl=G(()=>{\"use strict\";ge()});function Il(e,t,n){let i=vt.get(e);i?(i.fullRender=t,i.render2D=n):(i={glManager:e,fullRender:t,render2D:n,waiters:[]},vt.set(e,i));let o=Promise.withResolvers();return i.waiters.push(o),Vi||(Vi=Gl(Bl)),o.promise}function El(e,t){if(!zi.has(e)){t();return}let n=An.get(e);n||(n=[],An.set(e,n)),n.push(t)}function Pl(e){let t=vt.get(e);if(t){vt.delete(e);for(let n of t.waiters)n.resolve()}An.delete(e),zi.delete(e)}async function Bl(){let e=Array.from(vt.values());vt.clear();let t=new Map;for(let n of e){if(n.glManager.isContextLost()){for(let r of n.waiters)r.resolve();continue}let i=n.glManager.backendId,o=t.get(i);o?o.push(n):t.set(i,[n])}await Promise.all(Array.from(t.values()).map(lf)),Vi=0,vt.size>0&&(Vi=Gl(Bl))}async function lf(e){for(let t of e)await af(t)}async function af(e){zi.add(e.glManager);try{e.glManager.beginFrame(),e.fullRender()}catch(t){console.error(\"scheduler: fullRender threw\",t);for(let n of e.waiters)n.reject(t);Dl(e.glManager);return}try{await e.glManager.awaitGpuFence(),e.render2D(),e.glManager.endFrame();for(let t of e.waiters)t.resolve()}catch(t){console.error(\"scheduler: present failed\",t);try{e.glManager.endFrame()}catch{}for(let n of e.waiters)n.reject(t)}finally{Dl(e.glManager)}}function Dl(e){zi.delete(e);let t=An.get(e);if(t){An.delete(e);for(let n of t)try{n()}catch(i){console.error(\"scheduler: deferred op threw\",i)}}}function Gl(e){return typeof requestAnimationFrame==\"function\"?requestAnimationFrame(e):setTimeout(e,16)}var vt,Vi,zi,An,Or=G(()=>{\"use strict\";vt=new Map,Vi=0,zi=new Set,An=new Map});var uf,mf,De,Ln=G(()=>{\"use strict\";ll();al();ml();Ri();Pr();Nt();Ve();Rl();Sl();Or();uf=(()=>{let e=Mr(\"float\",void 0,Sr);return t=>e.format(t)})(),mf=(()=>{let e=Rr(void 0,Dr);return t=>e.format(t)})(),De=class{constructor(){p(this,\"i\",null);p(this,\"Q\",null);p(this,\"l\",null);p(this,\"Zo\",null);p(this,\"Fn\",[]);p(this,\"qo\",{});p(this,\"_\",null);p(this,\"Sn\",[]);p(this,\"L\",[]);p(this,\"h\",[]);p(this,\"B\",[]);p(this,\"je\",{});p(this,\"bi\",!1);p(this,\"gi\",!1);p(this,\"vt\",{});p(this,\"Dn\",{});p(this,\"to\",new Map);p(this,\"xi\");p(this,\"W\",{...pl});p(this,\"t\",{...Ue});p(this,\"F\",new Wi);p(this,\"w\",new Pi);p(this,\"yi\",null);p(this,\"_i\",Promise.resolve());p(this,\"dn\",null);p(this,\"Ko\",null);p(this,\"Oe\",null)}setGridlineCanvas(t){this.Q=t}setChromeCanvas(t){this.l=t}setOverlayPresenter(t){this.Zo=t}presentOverlay(){this.Zo?.()}setTheme(t){this.qo=t,this.dn=null}setZoomController(t){this._=t,t.configure(this.getZoomConfig())}getZoomControllerForFacet(t){if(this.W.zoom_mode===\"shared\")return this._;if(!this._)return null;let n=this.Sn[t];return n||(n=new kt,n.configure(this.getZoomConfig()),this.Sn[t]=n),n}computeEffectiveFacetFlags(){let t=this.W.zoom_mode===\"independent\",n=!t&&this.W.shared_x_axis,i=!t&&this.W.shared_y_axis;return this.bi=n,this.gi=i,{independentZoom:t,effectiveSharedX:n,effectiveSharedY:i}}syncFacetZoomLayouts(t){let n=this.W.zoom_mode===\"independent\";for(let i=0;i<t.length;i++)if(this.getZoomControllerForFacet(i)?.updateLayout(t[i].layout),!n)return}setZoomBaseDomain(t,n,i,o){this._&&this._.setBaseDomain(t,n,i,o);for(let r of this.Sn)r&&r.setBaseDomain(t,n,i,o)}getZoomConfig(){return{}}setColumnSlots(t){this.L=t}setViewPivots(t,n){this.h=t,this.B=n}setColumnTypes(t){this.je=t,this.Jo()}resetExpandedDomain(){}setGroupByTypes(t){this.vt=t}setColumnsConfig(t){this.Dn=t??{},this.Jo(),this.dn=null}Jo(){this.to=new Map;for(let[t,n]of Object.entries(this.Dn)){let i=this.je[t]??this.vt[t],o=this.Sr(i,n);o&&this.to.set(t,o)}}Sr(t,n){if(!(!t||!n)){if(t===\"integer\"||t===\"float\"){let i=n.number_format;if(!i)return;let o=Mr(t,i,Sr);return r=>o.format(r)}if(t===\"datetime\"){let i=n.date_format;if(!i)return;let o=Rr(i,Dr);return r=>o.format(r)}if(t===\"date\"){let i=n.date_format;if(!i)return;let o=sl(i,ul);return r=>o.format(r)}}}getColumnFormatter(t,n=\"value\"){if(t){let r=this.to.get(Fr(t));if(r)return r}if(n===\"tick\")return;let i=t?Fr(t):void 0,o=i?this.je[i]??this.vt[i]:void 0;return o===\"date\"||o===\"datetime\"?mf:uf}setDefaultChartType(t){this.xi=t}setFacetConfig(t){this.W={...t}}setPluginConfig(t){this.F.reconcileConfig(this.t,t),this.t={...t},this.W={...this.W,facet_mode:t.facet_mode,zoom_mode:t.facet_zoom_mode},this.Ci=t.series_zoom_mode===\"dynamic\"}colorScaleColumn(){return null}v(){let t=this.colorScaleColumn();return(!this.dn||this.Ko!==t)&&(this.Ko=t,this.dn=Fl(Ml(this.qo),this.Dn,t)),this.dn}invalidateTheme(){this.dn=null}setView(t){this.Oe&&this.Oe.dispose(),this.Oe=new Ii(t);let n=this.w.isPinned;this.w.dismiss(),n&&this.emitUnselect()}deselect(){this.w.dismiss()}tooltipCallbacks(){return{onHover:()=>{},onLeave:()=>{}}}attachTooltip(t){this.w.attach(this.tooltipCallbacks()),this.w.setHost(t),this.yi=t}async buildClickDetail(t){let n={};if(t.rowIdx!=null&&t.rowIdx>=0&&this.Oe)try{let o=await this.Oe.fetchRow(t.rowIdx);n=Object.fromEntries(o)}catch{n={}}let i=[];for(let o=0;o<this.h.length;o++){let r=t.groupByValues[o];r!=null&&r!==\"\"&&i.push([this.h[o],\"==\",r])}for(let o=0;o<this.B.length;o++){let r=t.splitByValues[o];r!=null&&r!==\"\"&&i.push([this.B[o],\"==\",r])}return{row:n,column_names:[t.columnName],config:{filter:i}}}emitUserClick(t){let n={row:t.row,column_names:t.column_names,config:t.config};this.yi?.emitUserClick?.(n)}emitUserSelect(t){let n={selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig};this.yi?.emitUserSelect?.(n)}emitClickAndSelect(t){let n=this._i.then(async()=>{let i=await this.buildClickDetail(t);this.emitUserClick(i),this.emitUserSelect({selected:!0,row:i.row,column_names:i.column_names,insertConfig:i.config})});return this._i=n.catch(i=>{console.error(\"emitClickAndSelect failed\",i)}),n}emitUnselect(t={}){let n=this._i.then(()=>{this.emitUserSelect({selected:!1,row:t.row??{},column_names:t.column_names??[],insertConfig:{filter:[]}})});this._i=n.catch(i=>{console.error(\"emitUnselect failed\",i)})}requestRender(t){return Il(t,()=>{this.Fn=[],this.kt(t)},()=>this.Qo())}_e(t){this.Fn.push(t)}Qo(){let t=this.Fn;this.Fn=[];for(let n of t)n()}renderFrameSync(t){this.Fn=[],this.kt(t),this.Qo()}destroy(){this.w.detach(),this.w.dismiss(),this.Oe&&(this.Oe.dispose(),this.Oe=null),this.destroyInternal()}}});var Yi,Wl=G(()=>{\"use strict\";Yi=class{constructor(t,n,i,o,r){p(this,\"ot\",new Map);p(this,\"Ce\");p(this,\"Se\");p(this,\"Nt\");p(this,\"er\");this.Ce=t,this.Se=i,this.Nt=r,this.er=Math.max(1,Math.ceil((n-t)/r))}tr(t,n){return n*this.er+t}insert(t,n,i){let o=Math.floor((n-this.Ce)/this.Nt),r=Math.floor((i-this.Se)/this.Nt),s=this.tr(o,r),l=this.ot.get(s);l||(l=[],this.ot.set(s,l)),l.push(t)}query(t,n,i,o,r,s,l){let a=Math.ceil(i/o/this.Nt),u=Math.ceil(i/r/this.Nt),m=Math.floor((t-this.Ce)/this.Nt),f=Math.floor((n-this.Se)/this.Nt),c=-1,d=i*i;for(let b=f-u;b<=f+u;b++)for(let g=m-a;g<=m+a;g++){let h=this.ot.get(this.tr(g,b));if(h)for(let x of h){let y=(s[x]-t)*o,C=(l[x]-n)*r,_=y*y+C*C;_<d&&(d=_,c=x)}}return c}}});var Xi,kl=G(()=>{\"use strict\";Wl();Xi=class{constructor(){p(this,\"In\",null);p(this,\"En\",!0)}markDirty(){this.En=!0}get isDirty(){return this.En}rebuild(t,n,i){if(n===0){this.In=null,this.En=!1;return}let o=t.xMax-t.xMin||1,r=t.yMax-t.yMin||1,l=(o+r)/2/Math.max(1,Math.sqrt(n)),a=new Yi(t.xMin,t.xMax,t.yMin,t.yMax,l);i((u,m,f)=>a.insert(u,m,f)),this.In=a,this.En=!1}query(t,n,i,o,r,s,l){return!this.In||!s||!l?-1:this.In.query(t,n,i,o,r,s,l)}clear(){this.In=null,this.En=!0}}});function it(e,t,n=[]){let i=new Map;for(let r of e.keys()){if(r.startsWith(\"__\"))continue;let s=r.lastIndexOf(\"|\");if(s===-1)continue;let l=r.substring(0,s);i.has(l)||i.set(l,new Set),i.get(l).add(r)}let o=[];for(let[r,s]of i){let l=new Map,a=!0;for(let u of t){if(!u)continue;let m=`${r}|${u}`,f=e.get(m);if(!s.has(m)||!f?.values){a=!1;break}l.set(u,m)}if(a){for(let u of n){if(!u)continue;let m=`${r}|${u}`;s.has(m)&&e.get(m)?.values&&l.set(u,m)}o.push({prefix:r,colNames:l})}}return o}var Tn=G(()=>{\"use strict\"});var $i,Nl=G(()=>{\"use strict\";$i=class{constructor(t){p(this,\"data\");p(this,\"dictionary\",[]);p(this,\"dictMap\",new Map);this.data=new Int32Array(t),this.data.fill(-1)}set(t,n){let i=this.dictMap.get(n);return i===void 0&&(i=this.dictionary.length,this.dictionary.push(n),this.dictMap.set(n,i)),this.data[t]=i,i}get(t){let n=this.data[t];return n<0?null:this.dictionary[n]}}});function Ol(e,t,n,i){let o;if(!e)o=\"(null)\";else{let s=e.valid;if(!(s?!!(s[t>>3]>>(t&7)&1):!0))o=\"(null)\";else if(e.indices&&e.dictionary)o=e.dictionary[e.indices[t]]??\"(null)\";else if(e.values){let a=e.values[t];o=a==null?\"(null)\":String(a)}else o=\"(null)\"}let r=i.get(o);return r===void 0&&(r=n.length,n.push(o),i.set(o,r)),r}function ff(e,t,n,i,o,r){let s=t?[t,n]:[n],l=[];return i&&l.push(i),o&&l.push(o),r&&l.push(r),it(e,s,l).map(a=>({prefix:a.prefix,xColName:t?a.colNames.get(t):\"\",yColName:a.colNames.get(n),colorColName:i?`${a.prefix}|${i}`:\"\",sizeColName:o?`${a.prefix}|${o}`:\"\",labelColName:r?`${a.prefix}|${r}`:\"\"}))}function Ul(e,t,n,i){e.glyph.ensureProgram(e,t);let o=e.s,r=e.k;e.t.domain_mode===\"expand\"?(e.Ce=e.Pn,e.rt=e.Bn,e.Se=e.Gn,e.st=e.Wn,e.p=e.vi,e.c=e.Ai,e.lt=e.Li,e.ut=e.Ti):(e.Ce=1/0,e.rt=-1/0,e.Se=1/0,e.st=-1/0,e.p=1/0,e.c=-1/0,e.lt=1/0,e.ut=-1/0,e.Pn=1/0,e.Bn=-1/0,e.Gn=1/0,e.Wn=-1/0,e.vi=1/0,e.Ai=-1/0,e.Li=1/0,e.Ti=-1/0),e.S=NaN,e.D=NaN,e.At=0,e.pn.clear(),e.no=0;let l=e.L,a=l[0]||\"\",u=l[1]||\"\",m=l[2]||\"\",f=l[3]||\"\",c=l[4]||\"\";e.Ue=a,e.De=u,e.nr=!a,e.He=!!a&&e.je[a]===\"string\",e.ve=!!u&&e.je[u]===\"string\",e.bn=[],e.gn=[],e.ir=new Map,e.or=new Map,e.mt=null,e.ft=null,e.He&&(e.S=0,e.Ce=0,e.rt=0,e.Pn=1/0,e.Bn=-1/0),e.ve&&(e.D=0,e.Se=0,e.st=0,e.Gn=1/0,e.Wn=-1/0);let d=t.A.totalCapacity||i;if(e.B.length>0){if(e.T=ff(n,a,u,m,f,c),e.T.length===0){e.M=0,e.X=[];return}if(e.Ze=e.T[0].xColName,e.Ve=e.T[0].yColName,e.s=m,e.re=f,e.wi=c,e.k=!1,m){let h=n.get(e.T[0].colorColName);e.k=h?.type===\"string\"}t.ensureBufferCapacity(d*e.T.length)}else if(e.T=[],e.Ze=a,e.Ve=u,e.s=m,e.re=f,e.wi=c,e.k=!1,e.s){let h=n.get(e.s);e.k=h?.type===\"string\"}(e.s!==o||e.k!==r)&&(e.a=new Map);let b=Math.max(1,e.T.length);e.M=d,e.X=new Array(b).fill(0);let g=b*d;e.$=new Float32Array(g),e.j=new Float32Array(g),e.Lt=new Float32Array(g),e.Ot=new Int32Array(g),e.Ut=c?new $i(g):null}function Hl(e,t,n,i,o,r){if(!e.Ve)return;let s=o;if(s===0||e.M===0)return;let l=e.T.length>0,a=[];if(l)for(let b of e.T){let g=b.xColName?n.get(b.xColName):null,h=n.get(b.yColName);if(!h||!e.ve&&!h.values)continue;let x=b.sizeColName?n.get(b.sizeColName):null,y=b.colorColName?n.get(b.colorColName)??null:null,C=b.labelColName?n.get(b.labelColName)??null:null;a.push({xCol:g?.values??null,yCol:h.values??null,xColData:g??null,yColData:h,xValid:g?.valid,yValid:h.valid,colorCol:y,sizeCol:x?.values??null,labelCol:C})}else{let b=e.Ze?n.get(e.Ze):null,g=e.Ve?n.get(e.Ve):null;if(!g||!e.ve&&!g.values)return;let h=e.s?n.get(e.s)??null:null,x=e.wi?n.get(e.wi)??null:null;a.push({xCol:b?.values??null,yCol:g.values??null,xColData:b??null,yColData:g,xValid:b?.valid,yValid:g?.valid,colorCol:h,sizeCol:null,labelCol:x})}if(a.length===0)return;e.rr<s&&(e.io=new Float32Array(s*2),e.oo=new Float32Array(s),e.ro=new Float32Array(s),e.rr=s);let u=e.io,m=e.oo,f=e.ro,c=!l&&e.re?n.get(e.re)?.values??null:null;if(e.k&&e.s){for(let b of a){let g=b.colorCol?.dictionary;if(g)for(let h=0;h<g.length;h++){let x=g[h];e.a.has(x)||e.a.set(x,e.a.size)}}e.a.size>0&&(e.p=0,e.c=e.a.size-1)}!e.s&&e.T.length>1&&(e.p=0,e.c=e.T.length-1);for(let b=0;b<a.length;b++){let g=a[b],h=e.X[b]??0,x=b*e.M,y=e.M-h;if(y<=0)continue;let C=g.colorCol?.valid,_=0;for(let L=0;L<s&&_<y;L++){let T=L;if(!e.ve&&g.yValid&&!(g.yValid[T>>3]>>(T&7)&1)||!e.He&&g.xCol&&g.xValid&&!(g.xValid[T>>3]>>(T&7)&1))continue;let w=C!==void 0&&!(C[T>>3]>>(T&7)&1),M;if(e.ve)M=Ol(g.yColData,T,e.gn,e.or);else if(g.yCol){if(M=g.yCol[T],isNaN(M))continue}else continue;let I;if(e.He)I=Ol(g.xColData,T,e.bn,e.ir);else if(g.xCol){if(I=g.xCol[T],isNaN(I))continue}else I=i+T;let[D,S]=e.projectPoint(I,M);if(isNaN(D)||isNaN(S))continue;D<e.Ce&&(e.Ce=D),D>e.rt&&(e.rt=D),S<e.Se&&(e.Se=S),S>e.st&&(e.st=S),isNaN(e.S)&&(e.S=D),isNaN(e.D)&&(e.D=S);let E=D-e.S,k=S-e.D,W=x+h+_;e.$[W]=E,e.j[W]=k,e.Ot[W]=i+T,u[_*2]=E,u[_*2+1]=k;let V=g.colorCol;if(w)m[_]=.5,e.Lt[W]=.5;else if(V&&!e.k&&V.values){let N=V.values[T];m[_]=N,e.Lt[W]=N,N<e.p&&(e.p=N),N>e.c&&(e.c=N)}else if(V&&e.k&&V.indices&&V.dictionary){let N=V.dictionary[V.indices[T]];e.a.has(N)||(e.a.set(N,e.a.size),e.c=e.a.size-1);let H=e.a.get(N);m[_]=H,e.Lt[W]=H}else m[_]=b,e.Lt[W]=b;if(e.Ut&&g.labelCol){let N=g.labelCol,H=N.valid;!(H!==void 0&&!(H[T>>3]>>(T&7)&1))&&N.indices&&N.dictionary&&e.Ut.set(W,N.dictionary[N.indices[T]])}if(g.sizeCol){let N=g.sizeCol[T];f[_]=N,N<e.lt&&(e.lt=N),N>e.ut&&(e.ut=N)}else if(c){let N=c[T];f[_]=N,N<e.lt&&(e.lt=N),N>e.ut&&(e.ut=N)}else f[_]=0;_++}if(_===0)continue;let v=(x+h)*2*Float32Array.BYTES_PER_ELEMENT;t.A.upload(\"a_position\",u.subarray(0,_*2),v,2);let A=(x+h)*Float32Array.BYTES_PER_ELEMENT;t.A.upload(\"a_color_value\",m.subarray(0,_),A),t.A.upload(\"a_size_value\",f.subarray(0,_),A),e.X[b]=h+_,e.X[b]>e.no&&(e.no=e.X[b])}let d=0;for(let b of e.X)d+=b;e.At=d,t.uploadedCount=d,e.pn.markDirty(),isFinite(e.Ce)&&e.setZoomBaseDomain(e.Ce,e.rt,e.Se,e.st)}var Vl=G(()=>{\"use strict\";Tn();Nl()});function Ut(e,t,n,i,o){let r=e.getContext(\"2d\");r&&(r.save(),r.setTransform(1,0,0,1,0,0),r.scale(o,o),r.font=`11px ${i.fontFamily}`,r.fillStyle=i.Fe,r.textAlign=\"center\",r.textBaseline=\"middle\",r.fillText(t,n.x+n.width/2,n.y+n.height/2),r.restore())}var ji=G(()=>{\"use strict\"});var oe,ot=G(()=>{\"use strict\";oe=class{constructor(t,n,i){p(this,\"margins\");p(this,\"e\");p(this,\"cssWidth\");p(this,\"cssHeight\");p(this,\"O\",0);p(this,\"Z\",1);p(this,\"q\",0);p(this,\"ee\",1);this.cssWidth=t,this.cssHeight=n;let r=(i.leftExtra??55)+(i.hasYLabel?16:0),l=(i.bottomExtra??24)+(i.hasXLabel?18:0),a=0,u=i.rightExtra??(i.hasLegend?80:16),m=i.originX??0,f=i.originY??0,c=i.cellWidth??t,d=i.cellHeight??n,b=m+r,g=f+a,h=Math.max(1,c-r-u),x=Math.max(1,d-a-l),y=t-(b+h),C=n-(g+x);this.margins={top:g,right:y,bottom:C,left:b},this.e={x:b,y:g,width:h,height:x}}buildProjectionMatrix(t,n,i,o,r,s,l=.02,a=0,u=0){let m=n-t,f=o-i;m===0&&(m=1),f===0&&(f=1);let c=m*l,d=f*l,b=s&&r===\"y\"&&i>=0,g=s&&r===\"y\"&&o<=0,h=s&&r===\"x\"&&t>=0,x=s&&r===\"x\"&&n<=0;t-=c,n+=c,i-=d,o+=d,b?(i=0,o+=d):g&&(o=0,i-=d),h?(t=0,n+=c):x&&(n=0,t-=c),this.O=t,this.Z=n,this.q=i,this.ee=o;let y=2*this.margins.left/this.cssWidth-1,C=1-2*this.margins.right/this.cssWidth,_=2*this.margins.bottom/this.cssHeight-1,v=1-2*this.margins.top/this.cssHeight,A=(C-y)/(n-t),L=(v-_)/(o-i),T=y-A*(t-a),w=_-L*(i-u);return new Float32Array([A,0,0,0,0,L,0,0,0,0,-1,0,T,w,0,1])}R(t,n){let{x:i,y:o,width:r,height:s}=this.e,l=(t-this.O)/(this.Z-this.O),a=(n-this.q)/(this.ee-this.q);return{px:i+l*r,py:o+(1-a)*s}}}});function wn(e){return e.cells.filter(t=>t.isBottomEdge).map(t=>t.layout)}function Mn(e){return e.cells.filter(t=>t.isLeftEdge).map(t=>t.layout)}function xf(e,t,n,i){if(e<=1)return{cols:1,rows:1};let o=1,r=e,s=1/0,l=e;for(let a=1;a<=e;a++){let u=Math.ceil(e/a),m=Math.max(1,(t-(a-1)*i)/a),f=Math.max(1,(n-(u-1)*i)/u),c=m/f,d=Math.max(c,1/c),b=a*u;(d<s||d===s&&b<l)&&(o=a,r=u,s=d,l=b)}return{cols:o,rows:r}}function Ie(e,t){let n=e.length,{cssWidth:i,cssHeight:o}=t;if(n<=0||i<=0||o<=0)return{cells:[]};let r=t.titleBand??gf,s=t.hasLegend?t.legendWidth??hf:0,l=t.xAxis??\"cell\",a=t.yAxis??\"cell\",u=l===\"none\"&&a===\"none\",m=a===\"outer\"?cf+(t.hasYLabel?pf:0):0,f=l===\"outer\"?df+(t.hasXLabel?bf:0):0,c=0,d=s,b=m,g=c,h=Math.max(1,i-m-d),x=Math.max(1,o-c-f),y=Math.max(0,t.gap??0),{cols:C,rows:_}=xf(n,h,x,y),v=Math.max(0,C-1)*y,A=Math.max(0,_-1)*y,L=Math.max(1,(h-v)/C),T=Math.max(1,(x-A)/_),w=[];for(let S=0;S<n;S++){let E=Math.floor(S/C),k=S-E*C,W=E===_-1||S+C>=n,V=k===0,N=b+k*(L+y),H=g+E*(T+y),U=H+r,Y=N,q=L,me=Math.max(1,T-r),Ge=new oe(i,o,{hasXLabel:l===\"cell\"&&t.hasXLabel===!0,hasYLabel:a===\"cell\"&&t.hasYLabel===!0,hasLegend:!1,leftExtra:a===\"cell\"?void 0:0,bottomExtra:l===\"cell\"?void 0:0,rightExtra:u?0:void 0,originX:Y,originY:U,cellWidth:q,cellHeight:me}),Re=r>0?{x:Y,y:H,width:q,height:r}:void 0;w.push({index:S,label:e[S],layout:Ge,titleRect:Re,isLeftEdge:V,isBottomEdge:W})}let M=t.hasLegend?{x:b+h,y:c,width:s,height:x}:void 0,I=l===\"outer\"?{x:b,y:g+x,width:h,height:f}:void 0;return{cells:w,legendRect:M,outerXAxisRect:I,outerYAxisRect:a===\"outer\"?{x:0,y:g,width:m,height:x}:void 0}}var cf,df,pf,bf,gf,hf,Ht=G(()=>{\"use strict\";ot();cf=55,df=24,pf=16,bf=18,gf=18,hf=96});function yf(e,t){if(t<=0)return[];let n=new Array(t);for(let i=0;i<t;i++){let o=t===1?.5:i/(t-1),r=Se(e,o);n[i]=[r[0],r[1],r[2]]}return n}function he(e,t,n){if(e.length>0){if(e.length>=n)return e.slice(0,n);let i=new Array(n);for(let o=0;o<n;o++)i[o]=e[o%e.length];return i}return yf(t,n)}var Rn=G(()=>{\"use strict\";ge()});function At(e){e.clearColor(0,0,0,0),e.clear(e.COLOR_BUFFER_BIT),e.enable(e.BLEND),e.blendFunc(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA)}function Lt(e,t,n,i){e.enable(e.SCISSOR_TEST),e.scissor(Math.round(t.margins.left*n),Math.round(t.margins.bottom*n),Math.round(t.e.width*n),Math.round(t.e.height*n));try{i()}finally{e.disable(e.SCISSOR_TEST)}}function rt(e,t,n,i){At(e),Lt(e,t,n,i)}var Fn=G(()=>{\"use strict\"});function Sn(e,t,n){let i=e.gl,o;if(t?.texture){if(o=t.texture,t.lastStops===n)return t}else o=i.createTexture();let r=Tl(n,zl);return i.bindTexture(i.TEXTURE_2D,o),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,zl,1,0,i.RGBA,i.UNSIGNED_BYTE,r),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),{texture:o,lastStops:n}}function ze(e,t,n,i=0){let o=e.gl;o.activeTexture(o.TEXTURE0+i),o.bindTexture(o.TEXTURE_2D,t),o.uniform1i(n,i)}var zl,Vt=G(()=>{\"use strict\";ge();zl=256});function Ye(e,t,n,i,o,r=1){if(!e||o.length===0)return;let s=e.getContext(\"2d\");if(!s)return;let l=t.e;s.save(),s.setTransform(1,0,0,1,0,0),s.scale(i,i),s.font=`11px ${n.fontFamily}`;for(let a of o)a.px<l.x||a.px>l.x+l.width||a.py<l.y||a.py>l.y+l.height||(_f(s,a,l,n),Cf(s,a,t,n,r));s.restore()}function _f(e,t,n,i){e.strokeStyle=i.Ct,e.lineWidth=1,e.setLineDash([4,4]),e.beginPath(),e.moveTo(t.px,t.py),t.side===\"bottom\"?e.lineTo(t.px,n.y+n.height):t.side===\"left\"?e.lineTo(n.x,t.py):e.lineTo(n.x+n.width,t.py),e.stroke(),e.setLineDash([])}function Cf(e,t,n,i,o){let r=n.e,s=e.measureText(t.text).width+8,l=17,a,u;t.side===\"bottom\"?(a=t.px-s/2,u=r.y+r.height+4):t.side===\"left\"?(a=r.x-4-s,u=t.py-l/2):(a=r.x+r.width+4,u=t.py-l/2),a=Math.min(Math.max(a,0),Math.max(0,n.cssWidth-s)),u=Math.min(Math.max(u,0),Math.max(0,n.cssHeight-l)),e.globalAlpha=Math.min(1,Math.max(0,o)),e.fillStyle=i.mi,e.strokeStyle=i.No,e.lineWidth=1,e.beginPath(),e.rect(a,u,s,l),e.fill(),e.stroke(),e.globalAlpha=1,e.fillStyle=i.Oo,e.textAlign=\"left\",e.textBaseline=\"middle\",e.fillText(t.text,a+4,u+l/2+1)}var Dn=G(()=>{\"use strict\"});function Yl(e,t){let n=Math.floor(Math.log10(e)),i=e/Math.pow(10,n),o;return t?i<1.5?o=1:i<3?o=2:i<7?o=5:o=10:i<=1?o=1:i<=2?o=2:i<=5?o=5:o=10,o*Math.pow(10,n)}function K(e,t,n){n<1&&(n=1);let i=Yl(t-e,!1),o=Yl(i/n,!0),r=Math.ceil(e/o)*o,s=Math.floor(t/o)*o,l=[];for(let a=r;a<=s+o*.001;a+=o)l.push(a);return l}function fe(e,t){if(!e)return Ee;let n=t&&t.length>1?t[1]-t[0]:0;return i=>Yt(i,n)}function Ee(e){if(!Number.isFinite(e))return\"-\";let t=Math.abs(e);return t===0?\"0\":t>=1e9?(e/1e9).toFixed(1)+\"B\":t>=1e6?(e/1e6).toFixed(1)+\"M\":t>=1e3?(e/1e3).toFixed(1)+\"K\":Number.isInteger(e)?e.toString():t>=1?e.toFixed(1):e.toFixed(2)}function zt(e,t){let n=Xl.get(e);return n||(n=new Intl.DateTimeFormat(void 0,t),Xl.set(e,n)),n}function Yt(e,t){let n=new Date(e);return isNaN(n.getTime())?Ee(e):t!==void 0&&t>0?t>=864e5*28?zt(\"ym\",{year:\"numeric\",month:\"short\"}).format(n):t>=864e5?zt(\"md\",{month:\"short\",day:\"numeric\"}).format(n):t>=36e5?zt(\"mdh\",{month:\"short\",day:\"numeric\",hour:\"numeric\"}).format(n):t>=6e4?zt(\"hm\",{hour:\"numeric\",minute:\"2-digit\"}).format(n):zt(\"hms\",{hour:\"numeric\",minute:\"2-digit\",second:\"2-digit\"}).format(n):zt(\"ymd\",{year:\"numeric\",month:\"short\",day:\"numeric\"}).format(n)}var Xl,Ce=G(()=>{\"use strict\";Xl=new Map});function ce(e,t,n){e.width=Math.round(t.cssWidth*n),e.height=Math.round(t.cssHeight*n);let i=e.getContext(\"2d\");return i?(i.scale(n,n),i.clearRect(0,0,t.cssWidth,t.cssHeight),i):null}function le(e,t){let n=e.getContext(\"2d\");return n?(n.setTransform(t,0,0,t,0,0),n):null}var Tt=G(()=>{\"use strict\"});function Zi(e,t,n,i,o,r,s){let l=o===\"bottom\"?1:-1;e.textAlign=\"center\",e.textBaseline=o===\"bottom\"?\"top\":\"bottom\";let a=l*8;for(let u of n){let m=r(u);m<t.x-1||m>t.x+t.width+1||(e.beginPath(),e.moveTo(m,i),e.lineTo(m,i+l*5),e.stroke(),e.fillText(s(u),m,i+a))}}function qi(e,t,n,i,o,r,s){let l=o===\"left\"?-1:1;e.textAlign=o===\"left\"?\"right\":\"left\",e.textBaseline=\"middle\";let a=l*8;for(let u of n){let m=r(u);m<t.y-1||m>t.y+t.height+1||(e.beginPath(),e.moveTo(i,m),e.lineTo(i+l*5,m),e.stroke(),e.fillText(s(u),i+a,m))}}function Xt(e,t,n,i){for(let o of n){let r=Math.round(i(o))+.5;r<t.x||r>t.x+t.width||(e.beginPath(),e.moveTo(r,t.y),e.lineTo(r,t.y+t.height),e.stroke())}}function $t(e,t,n,i){for(let o of n){let r=Math.round(i(o))+.5;r<t.y||r>t.y+t.height||(e.beginPath(),e.moveTo(t.x,r),e.lineTo(t.x+t.width,r),e.stroke())}}var Ki=G(()=>{\"use strict\"});function jt(e,t,n){let{e:i}=n,o=Math.max(2,Math.floor(i.width/90)),r=Math.max(2,Math.floor(i.height/60));return{xTicks:K(e.min,e.max,o),yTicks:K(t.min,t.max,r)}}function Ur(e,t,n,i,o,r){let s=le(e,r);if(!s)return;let{e:l}=t;s.strokeStyle=o.Rn,s.lineWidth=1,Xt(s,l,n,a=>t.R(a,0).px),$t(s,l,i,a=>t.R(0,a).py)}function $l(e,t,n){return n||fe(e.isDate,t)}function jl(e,t,n,i,o,r,s,l,a){let{Ct:u,Fe:m,di:f,fontFamily:c}=s,d=$l(t,n,a);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(r.x,o),e.lineTo(r.x+r.width,o),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${c}`;for(let b of i)Zi(e,b.e,n,o,\"bottom\",g=>b.R(g,0).px,d);l&&t.label&&(e.fillStyle=m,e.font=`13px ${c}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(t.label,l.cx,l.baselineY))}function Zl(e,t,n,i,o,r,s,l,a){let{Ct:u,Fe:m,di:f,fontFamily:c}=s,d=$l(t,n,a);e.strokeStyle=f,e.lineWidth=1,e.beginPath(),e.moveTo(o,r.y),e.lineTo(o,r.y+r.height),e.stroke(),e.fillStyle=u,e.strokeStyle=u,e.font=`11px ${c}`;for(let b of i)qi(e,b.e,n,o,\"left\",g=>b.R(0,g).py,d);l&&t.label&&(e.fillStyle=m,e.font=`13px ${c}`,e.save(),e.translate(14,l.pivotY),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(t.label,0,0),e.restore())}function Ji(e,t,n,i,o,r,s,l){let a=le(e,s);if(!a)return;let{e:u}=n;jl(a,t,i,[n],u.y+u.height,u,o,r?{cx:u.x+u.width/2,baselineY:n.cssHeight-2}:null,l)}function Qi(e,t,n,i,o,r,s,l){let a=le(e,s);if(!a)return;let{e:u}=n;Zl(a,t,i,[n],u.x,u,o,r?{pivotY:u.y+u.height/2}:null,l)}function In(e,t,n,i,o,r,s,l,a){let u=le(e,l);u&&jl(u,n,i,o,t.y,t,r,s?{cx:t.x+t.width/2,baselineY:t.y+t.height-2}:null,a)}function En(e,t,n,i,o,r,s,l,a){let u=le(e,l);u&&Zl(u,n,i,o,t.x+t.width,t,r,s?{pivotY:t.y+t.height/2}:null,a)}var Hr=G(()=>{\"use strict\";Ce();Tt();Ki()});function eo(e,t){if(t>Pn||t<-Pn)return[NaN,NaN];let n=e*Math.PI*6378137/180,i=t*Math.PI/180,o=6378137*Math.log(Math.tan(Math.PI/4+i/2));return[n,o]}function Zt(e,t){let n=e*180/(Math.PI*6378137),i=Math.atan(Math.exp(t/6378137))*360/Math.PI-90;return[n,i]}function ql(e,t,n){let i=1<<e,o=2*ve/i,r=-ve+t*o,s=r+o,l=ve-n*o,a=l-o;return{xMin:r,yMin:a,xMax:s,yMax:l}}function Kl(e,t=256,n=19){if(!isFinite(e)||e<=0)return 0;let i=Math.log2(2*ve/(t*e));return Math.max(0,Math.min(n,Math.floor(i)))}function Jl(e,t){let n=1<<t,i=2*ve/n,o=Math.floor((e.xMin+ve)/i),r=Math.floor((e.xMax+ve)/i),s=Math.floor((ve-e.yMax)/i),l=Math.floor((ve-e.yMin)/i),a=[];for(let u=s;u<=l;u++)if(!(u<0||u>=n))for(let m=o;m<=r;m++)m<0||m>=n||a.push({z:t,x:m,y:u});return a}var ve,Pn,Bn=G(()=>{\"use strict\";ve=Math.PI*6378137,Pn=85.0511287798066});function Gn(e){let t=e.e,n=Math.max(2,Math.floor(t.width/90)),i=Math.max(2,Math.floor(t.height/60)),o=Vr(e.O),r=Vr(e.Z),s=Ql(Zt(0,e.q)[1]),l=Ql(Zt(0,e.ee)[1]),a=ea(o,r,n),u=ea(s,l,i),m=ta(a),f=ta(u);return{xTicks:a.map(c=>c/180*ve),yTicks:u.map(c=>eo(0,c)[1]),formatX:c=>na(Vr(c),m,\"E\",\"W\"),formatY:c=>na(Zt(0,c)[1],f,\"N\",\"S\")}}function Vr(e){return e/ve*180}function Ql(e){return Math.max(-Pn,Math.min(Pn,e))}function ea(e,t,n){return!isFinite(e)||!isFinite(t)||t<=e?[]:K(e,t,n)}function ta(e){return e.length>1?Math.abs(e[1]-e[0]):1}function na(e,t,n,i){let o=t>=1?0:Math.min(6,Math.ceil(-Math.log10(t)+1e-9)),r=String(parseFloat(Math.abs(e).toFixed(o)));return parseFloat(r)===0?\"0\\xB0\":`${r}\\xB0${e>0?n:i}`}var ia=G(()=>{\"use strict\";Ce();Bn()});function zr(e,t,n,i,o){if(o===0)return{x:e-n/2,y:t,width:n,height:i};if(o===90)return{x:e-i/2,y:t,width:i,height:n};let r=(n+i)/Math.SQRT2;return{x:e-r,y:t,width:r,height:r}}function Yr(e,t){return e.x<=t.x+t.width&&t.x<=e.x+e.width&&e.y<=t.y+t.height&&t.y<=e.y+e.height}function oa(e,t){return e.x+e.width+14>t.x+t.width}function Xr(e,t){return e.x>=t.x&&e.x+e.width<=t.x+t.width&&e.y>=t.y&&e.y+e.height<=t.y+t.height}function wt(e,t,n){if(n<=0)return\"\";if(e.measureText(t).width<=n)return t;let i=0,o=t.length;for(;i<o;){let r=i+o+1>>1,s=t.slice(0,r)+\"\\u2026\";e.measureText(s).width<=n?i=r:o=r-1}return i===0?\"\":t.slice(0,i)+\"\\u2026\"}function ra(e,t,n,i){if(i<=0||n<=0)return[];if(e.measureText(t).width<=n)return[t];let o=[],r=t;for(;r.length>0&&o.length<i;){let s=o.length===i-1,l=r.length;for(;l>0&&e.measureText(r.slice(0,l)).width>n;)l--;if(l===0&&(l=1),l===r.length){o.push(r);break}let a=l,u=r.lastIndexOf(\" \",l);if(u>0&&(a=u),s){o.push(wt(e,r,n));break}o.push(r.slice(0,a)),r=r.slice(a).trimStart()}return o.length===1&&o[0].length<=2?[]:o}var to=G(()=>{\"use strict\"});function no(e,t,n,i){let o=[];if(i<=n)return o;let r=n,s=e[n];for(let l=n+1;l<i;l++){let a=e[l];a!==s&&(o.push({startIdx:r,endIdx:l-1,label:t[s]??\"\"}),r=l,s=a)}return o.push({startIdx:r,endIdx:i-1,label:t[s]??\"\"}),o}function Wn(e,t,n){if(n<t)return[];let i=[];for(let o of e){if(o.endIdx<t||o.startIdx>n)continue;let r=o.startIdx<t?t:o.startIdx,s=o.endIdx>n?n:o.endIdx;r===o.startIdx&&s===o.endIdx?i.push(o):i.push({startIdx:r,endIdx:s,label:o.label})}return i}var kn=G(()=>{\"use strict\"});function $r(e,t){return e.R(t,0).px}function jr(e,t){return e.R(0,t).py}function Mf(e,t,n){let i=Math.max(0,n-100);return e*16>i?{size:t*6.62+10,rotation:90}:e*(t*6+10)>i?{size:t*4+20,rotation:45}:{size:vf,rotation:0}}function sa(e,t){let n=e.levels.length,i=[];for(let o=0;o<n;o++){let r=e.levels[o];o===n-1?i.push(Mf(e.numRows,r.maxLabelChars,t)):i.push({size:Af,rotation:0})}return i}function la(e){let t=e.levels.length,n=[],i=6.2;for(let o=0;o<t;o++)if(o===t-1){let r=e.levels[o].maxLabelChars;n.push(Math.max(Lf,r*i+wf))}else n.push(Tf);return n}function aa(e){let t=0;for(let n of e)t+=n;return t}function Xe(e,t){return e.numRows===0||e.levels.length===0?24:aa(sa(e,t).map(n=>n.size))}function Kt(e){return e.numRows===0||e.levels.length===0?55:aa(la(e))}function Rf(e,t,n,i){let o=t-e+1;if(o<=0)return[];let r=Math.max(1,Math.floor(n/i));if(o<=r){let a=[];for(let u=e;u<=t;u++)a.push(u);return a}let s=Math.ceil(o/r),l=[];for(let a=e;a<=t;a+=s)l.push(a);return l}function ua(e,t){return e.labels[t]??\"\"}function ma(e,t,n,i){let o=i?Math.min(t,n):t,r=i?Math.max(t,n):n,s=Math.max(0,Math.ceil(o)),l=Math.min(e-1,Math.floor(r));return l<s?null:[s,l]}function fa(e,t,n,i){let o=[];for(let r of e){let s=t(r.startIdx-.5),l=t(r.endIdx+.5),a=Math.max(n,Math.min(s,l)),u=Math.min(i,Math.max(s,l));u>a&&o.push({run:r,nearEdge:s,farEdge:l,nearClip:a,farClip:u})}return o}function xe(e,t,n,i){if(n.numRows===0||n.levels.length===0)return;let{Ct:o,Fe:r,fontFamily:s}=i,{e:l}=t,a=l.y+l.height;e.strokeStyle=o,e.fillStyle=o,e.lineWidth=1,e.font=`${qt}px ${s}`;let u=sa(n,l.width),m=ma(n.numRows,t.O,t.Z,!1);if(!m)return;let[f,c]=m,d=n.levels.length,b=a;for(let h=d-1;h>=0;h--){let x=n.levels[h],y=u[h],C=b;b+=y.size,h===d-1?Ff(e,t,x,f,c,C,y,s,o):Sf(e,t,x,f,c,C,s,o)}let g=n.levelLabels.filter(h=>!!h).join(\" / \");g&&(e.fillStyle=r,e.font=`13px ${s}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(g,l.x+l.width/2,t.cssHeight-2))}function Ff(e,t,n,i,o,r,s,l,a){let{e:u}=t,f=Math.max(40,Math.min(n.maxLabelChars*6.2+8,u.width/2)),c=s.rotation===0?Rf(i,o,u.width,f):Df(i,o);e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let h of c){let x=$r(t,h);x<u.x-1||x>u.x+u.width+1||(e.moveTo(x,r),e.lineTo(x,r+io))}e.stroke(),e.font=`${qt}px ${l}`;let d=r+io+3,b={x:u.x,width:u.width,y:r,height:9999},g=[];for(let h of c){let x=$r(t,h);if(x<u.x-1||x>u.x+u.width+1)continue;let y=ua(n,h);if(!y)continue;let C=e.measureText(y).width,_=zr(x,d,C,Zr,s.rotation);if(Xr(_,b)){if(s.rotation===0){if(g.some(v=>Yr(v,_)))continue}else if(g.some(v=>oa(v,_)))continue;g.push(_),ca(e,y,x,d,s.rotation,\"center\")}}}function Sf(e,t,n,i,o,r,s,l){let{e:a}=t,u=Wn(n.runs,i,o);if(u.length===0)return;let m=fa(u,b=>$r(t,b),a.x,a.x+a.width);if(m.length===0)return;e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let b of m)e.moveTo(b.nearClip,r+3),e.lineTo(b.farClip,r+3),e.moveTo(b.nearEdge,r),e.lineTo(b.nearEdge,r+3),e.moveTo(b.farEdge,r),e.lineTo(b.farEdge,r+3);e.stroke(),e.font=`${qt}px ${s}`;let f=r+3+4,c=[],d={x:a.x,width:a.width,y:r,height:9999};for(let b of m){let g=(b.nearClip+b.farClip)/2,h=b.run.label;if(!h)continue;let x=b.farClip-b.nearClip-4,y=wt(e,h,x);if(!y)continue;let C=e.measureText(y).width,_=zr(g,f,C,Zr,0);Xr(_,d)&&(c.some(v=>Yr(v,_))||(c.push(_),ca(e,y,g,f,0,\"center\")))}}function Df(e,t){let n=[];for(let i=e;i<=t;i++)n.push(i);return n}function Pe(e,t,n,i){if(n.numRows===0||n.levels.length===0)return;let{Ct:o,Fe:r,fontFamily:s}=i,{e:l}=t,a=l.x;e.strokeStyle=o,e.fillStyle=o,e.lineWidth=1,e.font=`${qt}px ${s}`;let u=la(n),m=ma(n.numRows,t.q,t.ee,!0);if(!m)return;let[f,c]=m,d=n.levels.length,b=a;for(let h=d-1;h>=0;h--){let x=n.levels[h],y=u[h],C=b;b-=y,h===d-1?If(e,t,x,f,c,C,s,o):Ef(e,t,x,f,c,C,y,s,o)}let g=n.levelLabels.filter(h=>!!h).join(\" / \");g&&(e.fillStyle=r,e.font=`13px ${s}`,e.save(),e.translate(14,l.y+l.height/2),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(g,0,0),e.restore())}function If(e,t,n,i,o,r,s,l){let{e:a}=t,u=Zr+4,m=o-i+1,f=Math.max(1,Math.floor(a.height/u)),c=m<=f?1:Math.ceil(m/f);e.strokeStyle=l,e.fillStyle=l,e.beginPath();for(let d=i;d<=o;d+=c){let b=jr(t,d);b<a.y-1||b>a.y+a.height+1||(e.moveTo(r-io,b),e.lineTo(r,b))}e.stroke(),e.font=`${qt}px ${s}`,e.textAlign=\"right\",e.textBaseline=\"middle\";for(let d=i;d<=o;d+=c){let b=jr(t,d);if(b<a.y-1||b>a.y+a.height+1)continue;let g=ua(n,d);g&&e.fillText(g,r-io-3,b)}}function Ef(e,t,n,i,o,r,s,l,a){let{e:u}=t,m=Wn(n.runs,i,o);if(m.length===0)return;let f=fa(m,d=>jr(t,d),u.y,u.y+u.height);if(f.length===0)return;e.strokeStyle=a,e.fillStyle=a;let c=r-3;e.beginPath();for(let d of f)e.moveTo(c,d.nearClip),e.lineTo(c,d.farClip),e.moveTo(c,d.nearEdge),e.lineTo(r,d.nearEdge),e.moveTo(c,d.farEdge),e.lineTo(r,d.farEdge);e.stroke(),e.font=`${qt}px ${l}`,e.textAlign=\"right\",e.textBaseline=\"middle\";for(let d of f){let b=(d.nearClip+d.farClip)/2,g=d.run.label;if(!g)continue;let h=s-6,x=wt(e,g,h);x&&e.fillText(x,c-3,b)}}function ca(e,t,n,i,o,r){if(o===0){e.textAlign=r===\"end\"?\"right\":\"center\",e.textBaseline=\"top\",e.fillText(t,n,i);return}e.save(),e.translate(n,i),e.rotate(-o*Math.PI/180),e.textAlign=\"right\",e.textBaseline=\"middle\",e.fillText(t,-2,0),e.restore()}var vf,Af,io,qt,Zr,Lf,Tf,wf,Jt=G(()=>{\"use strict\";to();kn();vf=25,Af=22,io=5,qt=11,Zr=14,Lf=55,Tf=60,wf=10});function Pf(e){return`rgb(${Math.round(e[0]*255)},${Math.round(e[1]*255)},${Math.round(e[2]*255)})`}function st(e,t,n,i,o={}){return{entryCount:n,boxWidth:()=>{let r=e?.getContext(\"2d\");if(!r)return 0;r.save();let s=0,l=0;r.font=`${o.fontPx??11}px ${t.fontFamily}`;for(let m of i())if(s=Math.max(s,r.measureText(m).width),++l>=Bf)break;let a=0;o.title&&(r.font=`bold 10px ${t.fontFamily}`,a=r.measureText(o.title).width+Wr),r.restore();let u=o.leading??_l;return Math.ceil(Math.max(a,u+s+Gr))}}}function Rt(e,t,n,i=Ee,o){return st(e,t,0,()=>[i(n.max),i((n.min+n.max)/2),i(n.min)],{title:o,leading:da+pa,fontPx:10})}function ro(e,t,n,i,o=1){return e.save(),e.fillStyle=n.backgroundColor,e.strokeStyle=n.eo,e.lineWidth=1,e.beginPath(),e.rect(t.x+.5,t.y+.5,t.width-1,t.height-1),e.globalAlpha=Math.min(1,Math.max(0,o)),e.fill(),e.globalAlpha=1,e.stroke(),e.beginPath(),e.moveTo(t.x+.5,t.y+tt+.5),e.lineTo(t.x+t.width-.5,t.y+tt+.5),e.stroke(),i&&(e.fillStyle=n.cn,e.font=`bold 10px ${n.fontFamily}`,e.textAlign=\"left\",e.textBaseline=\"middle\",e.fillText(Mt(e,i,Math.max(0,t.width-Wr)),t.x+8,t.y+tt/2+.5)),e.restore(),{x:t.x+yl,y:t.y+tt+ki/2,width:Math.max(0,t.width-Gr),height:Math.max(0,t.height-tt-ki)}}function qr(e,t,n,i,o){if(i<=t.height)return;let r=t.x+t.width-oo,s=Math.max(20,t.height/i*t.height),l=t.height-s,a=i-t.height,u=t.y+(a>0?n/a*l:0);e.save(),e.fillStyle=o.eo,e.fillRect(r,t.y,oo,t.height),e.fillStyle=o.cn,e.fillRect(r,u,oo,s),e.restore()}function Mt(e,t,n){if(n<=0)return\"\";if(e.measureText(t).width<=n)return t;let i=0,o=t.length;for(;i<o;){let r=Math.ceil((i+o)/2);e.measureText(t.slice(0,r)+\"\\u2026\").width<=n?i=r:o=r-1}return i>0?t.slice(0,i)+\"\\u2026\":\"\\u2026\"}function Qt(e,t,n,i,o,r,s){let l={x:t.e.x+t.e.width+12,y:t.margins.top+20,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};$e(e,l,n,i,o,r,s&&{...s,sidebarGutter:t.margins.right})}function $e(e,t,n,i,o,r=Ee,s){let l=e.getContext(\"2d\");if(!l)return;let a=o.cn,u=o.eo,m=o.fontFamily,f=s?.mode===\"floating\",c,d,b,g=t,h=da;f?(g=ro(l,t,o,n.label,s?.opacity),c=g.x,d=g.y+4,b=Math.max(8,g.height-12)):(c=t.x,d=t.y,b=Math.min(120,t.height*.4),l.fillStyle=a,l.font=`9px ${m}`,l.textAlign=\"left\",l.textBaseline=\"bottom\",l.fillText(n.label,c,d-4));let x=n.max,y=n.min,C=l.createLinearGradient(0,d,0,d+b),_=16;for(let L=0;L<=_;L++){let T=L/_,w=x+T*(y-x),M=Ct(w,n.min,n.max),I=Se(i,M);C.addColorStop(T,Pf(I))}l.fillStyle=C,l.fillRect(c,d,h,b),l.strokeStyle=u,l.lineWidth=1,l.strokeRect(c,d,h,b),l.fillStyle=a,l.font=`10px ${m}`,l.textAlign=\"left\",l.textBaseline=\"middle\";let v=c+h+pa,A=Math.max(0,g.x+g.width-v);if(l.fillText(Mt(l,r(n.max),A),v,d+2),l.fillText(Mt(l,r((n.min+n.max)/2),A),v,d+b/2),l.fillText(Mt(l,r(n.min),A),v,d+b-2),n.min<0&&n.max>0){let L=(n.max-0)/(n.max-n.min),T=d+L*b;l.strokeStyle=a,l.lineWidth=1,l.beginPath(),l.moveTo(c+h,T),l.lineTo(c+h+4,T),l.stroke(),l.fillStyle=a,l.fillText(\"0\",v,T)}s&&s.legend.setPainted({mode:s.mode,box:t,content:g,contentHeight:Math.min(g.height,b+8),sidebarGutter:s.sidebarGutter})}function so(e,t,n,i,o,r){let s={x:t.e.x+t.e.width+12,y:t.margins.top+10,width:Math.max(1,t.cssWidth-t.e.x-t.e.width-12),height:Math.max(1,t.e.height)};Ft(e,s,n,i,o,r&&{...r,sidebarGutter:t.margins.right})}function Ft(e,t,n,i,o,r){let s=e.getContext(\"2d\");if(!s)return;if(n.size===0){r?.legend.clearPainted();return}let l=o.cn,a=o.fontFamily,u=r?.mode===\"floating\",m=t;u&&(m=ro(s,t,o,r?.title??\"Legend\",r?.opacity));let f=10,c=vn,d=n.size*c,b=r?r.legend.clampScroll(m.height,d):0,g=d>m.height,h=Math.max(0,m.width-f-6-(g?oo+4:0));s.save(),s.beginPath(),s.rect(m.x,m.y,m.width,m.height),s.clip(),s.font=`11px ${a}`,s.textAlign=\"left\",s.textBaseline=\"middle\";let x=Math.floor(b/c),y=m.x,C=0,_=m.y+c/2+x*c-b;for(let[v,A]of n){if(C<x){C++;continue}if(_-c/2>=m.y+m.height)break;let L=i[A]??i[A%i.length]??[0,0,0];s.fillStyle=`rgb(${Math.round(L[0]*255)},${Math.round(L[1]*255)},${Math.round(L[2]*255)})`,s.fillRect(y,_-f/2,f,f),s.fillStyle=l,s.fillText(Mt(s,v,h),y+f+6,_),_+=c,C++}s.restore(),qr(s,m,b,d,o),r&&r.legend.setPainted({mode:r.mode,box:t,content:m,contentHeight:d,sidebarGutter:r.sidebarGutter})}var oo,da,pa,Bf,Nn=G(()=>{\"use strict\";Ce();Ve();ge();oo=4,da=16,pa=5;Bf=64});function lt(e){return isNaN(e)?0:e}function On(e){return e.k?e.a.size:0}function ba(e,t){let n=e.s??void 0;return e.k?st(e.l,t,e.a.size,()=>e.a.keys(),{title:n}):Rt(e.l,t,{min:e.p,max:e.c},e.s?e.getColumnFormatter(e.s,\"value\"):void 0,n)}function ga(e,t){let n=t.gl,i=t.dpr,o=n.canvas.width/i,r=n.canvas.height/i;if(o<=0||r<=0)return;let s=e.T.length>0,l=e.W.facet_mode,a=s&&l===\"grid\";e.computeEffectiveFacetFlags();let u=e.s!==\"\"&&e.p<e.c,m=a&&e.W.zoom_mode===\"independent\",f;if(e._&&!m?f=e._.getVisibleDomain():f={xMin:e.Ce,xMax:e.rt,yMin:e.Se,yMax:e.st},!isFinite(f.xMin)||!isFinite(f.yMin))return;let c=e.v(),d=c.Ne,b=e.je[e.Ue]||\"\",g=e.je[e.De]||\"\",h=b===\"date\"||b===\"datetime\",x=g===\"date\"||g===\"datetime\",y=e.k,C=!y&&!e.s,_=c.N;if(y||C){let v=C?Math.max(1,e.T.length):Math.max(1,e.a.size);if(e.Mi&&e.so===d&&e.ao===v)_=e.Mi;else{let A=he(d,c.N,v);_=Ll(A),e.Mi=_,e.so=d,e.ao=v}}else e.Mi=null,e.so=null,e.ao=-1;e.se=Sn(t,e.se,_),a?kf(e,t,f,c,{xIsDate:h,yIsDate:x,cssWidth:o,cssHeight:r}):(e.b=null,Wf(e,t,f,c,{xIsDate:h,yIsDate:x,cssWidth:o,cssHeight:r,hasColorCol:u})),e._e(()=>je(e))}function lo(e,t,n,i){return{min:t,max:n,label:e.Ue||(e.nr?\"Row\":e.Ze||\"\"),isDate:i}}function ao(e,t,n,i){return{min:t,max:n,label:e.De||e.Ve,isDate:i}}function uo(e,t){let n=0;for(let o of e)o.length>n&&(n=o.length);return{levels:[{labels:e.slice(),runs:[],maxLabelChars:n}],numRows:e.length,levelLabels:[t]}}function Gf(e,t,n,i,o,r,s,l,a){if(e.He&&e.mt){let u=le(t,a);u&&xe(u,n,e.mt,l)}else Ji(t,i,n,r,l,!0,a,e.getColumnFormatter(e.Ze,\"tick\"));if(e.ve&&e.ft){let u=le(t,a);u&&Pe(u,n,e.ft,l)}else Qi(t,o,n,s,l,!0,a,e.getColumnFormatter(e.Ve,\"tick\"))}function Wf(e,t,n,i,o){let r=t.gl,{cssWidth:s,cssHeight:l,xIsDate:a,yIsDate:u,hasColorCol:m}=o;e.mt=e.He&&e.bn.length>0?uo(e.bn,e.Ue||e.Ze||\"\"):null,e.ft=e.ve&&e.gn.length>0?uo(e.gn,e.De||e.Ve||\"\"):null;let f=nt(e.t,m,80,On(e)),c=55+(e.De?16:0),d=Math.max(1,s-c-f),b=e.ft?Kt(e.ft):void 0,g=e.mt?Xe(e.mt,d):void 0,h=e.Ht===\"map\",x=h&&!e.t.numeric_axes,y=new oe(s,l,x?{hasXLabel:!1,hasYLabel:!1,hasLegend:m,leftExtra:0,bottomExtra:0,rightExtra:m&&se(e.t,On(e))===\"sidebar\"?we(e.t,80):0}:{hasXLabel:!!e.Ue,hasYLabel:!!e.De,hasLegend:m,leftExtra:b,bottomExtra:g,rightExtra:f});e.u=y,e._&&e._.updateLayout(y);let C=y.buildProjectionMatrix(n.xMin,n.xMax,n.yMin,n.yMax,void 0,void 0,void 0,lt(e.S),lt(e.D)),_=lo(e,n.xMin,n.xMax,a),v=ao(e,n.yMin,n.yMax,u),A=jt(_,v,y),L=e.He?[]:A.xTicks,T=e.ve?[]:A.yTicks,w=t.dpr,M=e.Q;M&&!h?e._e(()=>{ce(M,y,w),Ur(M,y,L,T,i,w)}):M&&h&&e._e(()=>ce(M,y,w)),rt(r,y,t.dpr,()=>{h&&e.renderBackground(t,y,C,n,lt(e.S),lt(e.D)),e.glyph.draw(e,t,C)}),e.le=_,e.te=v,e.kn=L,e.ae=T,e.Ri=i.N,e.Fi=m}function kf(e,t,n,i,o){let r=t.gl,{cssWidth:s,cssHeight:l,xIsDate:a,yIsDate:u}=o;e.mt=e.He&&e.bn.length>0?uo(e.bn,e.Ue||e.Ze||\"\"):null,e.ft=e.ve&&e.gn.length>0?uo(e.gn,e.De||e.Ve||\"\"):null;let m=e.T.map(M=>M.prefix),f=e.k&&e.a.size>1,c=!!e.s&&!e.k&&e.p<e.c,d=f||c,b=e.Ht===\"map\",g=b&&!e.t.numeric_axes,h=Ie(m,{cssWidth:s,cssHeight:l,xAxis:g?\"none\":e.bi?\"outer\":\"cell\",yAxis:g?\"none\":e.gi?\"outer\":\"cell\",hasLegend:d&&se(e.t,On(e))===\"sidebar\",legendWidth:we(e.t,96),hasXLabel:!g&&!!e.Ue,hasYLabel:!g&&!!e.De,gap:e.W.facet_padding});if(e.b=h,h.cells.length>1){let M=h.cells[0].layout.e;for(let I=1;I<h.cells.length;I++){let D=h.cells[I].layout.e;if(D.width!==M.width||D.height!==M.height){console.warn(`facet-grid: cell ${I} size (${D.width}\\xD7${D.height}) differs from cell 0 (${M.width}\\xD7${M.height})`);break}}}e.u=h.cells[0]?.layout??null,e.syncFacetZoomLayouts(h.cells);let x=e.W.zoom_mode===\"independent\",y=lo(e,n.xMin,n.xMax,a),C=ao(e,n.yMin,n.yMax,u),_=h.cells[0]?.layout,v=_?jt(y,C,_):{xTicks:[],yTicks:[]},A=e.He?[]:v.xTicks,L=e.ve?[]:v.yTicks,T=t.dpr,w=e.Q;w&&_&&e._e(()=>ce(w,_,T)),At(r);for(let M=0;M<h.cells.length;M++){let I=h.cells[M],D=e.getZoomControllerForFacet(M),S=x&&D?D.getVisibleDomain():n,E=I.layout.buildProjectionMatrix(S.xMin,S.xMax,S.yMin,S.yMax,void 0,void 0,void 0,lt(e.S),lt(e.D));w&&!b&&e._e(()=>{let k=x?jt(lo(e,S.xMin,S.xMax,a),ao(e,S.yMin,S.yMax,u),I.layout).xTicks:A,W=x?jt(lo(e,S.xMin,S.xMax,a),ao(e,S.yMin,S.yMax,u),I.layout).yTicks:L;Ur(w,I.layout,k,W,i,T)}),Lt(r,I.layout,t.dpr,()=>{b&&e.renderBackground(t,I.layout,E,S,lt(e.S),lt(e.D)),e.glyph.drawSeries(e,t,E,M)})}e.le=y,e.te=C,e.kn=A,e.ae=L,e.Ri=i.N,e.Fi=d}function je(e){Nf(e),e.presentOverlay()}function Nf(e){!e.l||!e.u||!e.le||!e.te||!e.i||(ce(e.l,e.u,e.i.dpr),e.b?Uf(e):Of(e))}function Of(e){let t=e.u,n=e.v(),i=e.i?.dpr??1;if(e.Ht===\"map\"){if(e.t.numeric_axes){let l=Gn(t);Ji(e.l,e.le,t,l.xTicks,n,!!e.Ue,i,l.formatX),Qi(e.l,e.te,t,l.yTicks,n,!!e.De,i,l.formatY)}e.renderMapChrome(e.l,t,n,i)}else Gf(e,e.l,t,e.le,e.te,e.kn,e.ae,n,i);let r=se(e.t,On(e)),s=!1;if(e.Fi&&r!==\"none\"){let l=e.Ri??n.N,a=r===\"floating\",u={mode:a?\"floating\":\"sidebar\",legend:e.F,title:e.s??void 0,opacity:e.t.legend_opacity},m=a?e.F.floatingBox(e.t,t.cssWidth,t.cssHeight,ba(e,n)):null;if(e.k&&e.a.size>0){let f=he(n.Ne,l,e.a.size);m?Ft(e.l,m,e.a,f,n,u):so(e.l,t,e.a,f,n,u),s=!0}else if(e.s){let f={min:e.p,max:e.c,label:e.s},c=e.getColumnFormatter(e.s,\"value\");m?$e(e.l,m,f,l,n,c,u):Qt(e.l,t,f,l,n,c,u),s=!0}}s||e.F.clearPainted(),ha(e,e.l,t,0,1),e.de>=0&&e.$&&e.j&&zf(e,e.l,t)}function Uf(e){let t=e.b,n=e.l,i=e.v(),o=e.i?.dpr??1,r=e.kn,s=e.ae,l=e.le,a=e.te,u=e.Ht===\"map\",m=e.bi&&!e.He,f=e.gi&&!e.ve,c=e.W.zoom_mode===\"independent\",d=u&&e.t.numeric_axes,b=d&&t.cells.length>0?Gn(t.cells[0].layout):null;u&&e.renderMapChrome(n,e.u,i,o),(!u||b)&&m&&t.outerXAxisRect&&In(n,t.outerXAxisRect,l,b?b.xTicks:r,wn(t),i,!!e.Ue,o,b?b.formatX:e.getColumnFormatter(e.Ze,\"tick\")),(!u||b)&&f&&t.outerYAxisRect&&En(n,t.outerYAxisRect,a,b?b.yTicks:s,Mn(t),i,!!e.De,o,b?b.formatY:e.getColumnFormatter(e.Ve,\"tick\"));for(let C=0;C<t.cells.length;C++){let _=t.cells[C],v=c?e.getZoomControllerForFacet(C):null,A=v?v.getVisibleDomain():null,L=A?{...l,min:A.xMin,max:A.xMax}:l,T=A?{...a,min:A.yMin,max:A.yMax}:a,w=d?Gn(_.layout):null,M=w||(c?jt(L,T,_.layout):{xTicks:r,yTicks:s});if((!u||w)&&!m)if(e.He&&e.mt){let I=le(n,o);I&&xe(I,_.layout,e.mt,i)}else Ji(n,L,_.layout,M.xTicks,i,!!e.Ue,o,w?w.formatX:e.getColumnFormatter(e.Ze,\"tick\"));if((!u||w)&&!f)if(e.ve&&e.ft){let I=le(n,o);I&&Pe(I,_.layout,e.ft,i)}else Qi(n,T,_.layout,M.yTicks,i,!!e.De,o,w?w.formatY:e.getColumnFormatter(e.Ve,\"tick\"));_.titleRect&&Ut(n,_.label,_.titleRect,i,o),ha(e,n,_.layout,C,C+1)}let g=se(e.t,On(e)),h=g===\"floating\",x=h?e.F.floatingBox(e.t,e.u.cssWidth,e.u.cssHeight,ba(e,i)):t.legendRect,y=!1;if(e.Fi&&g!==\"none\"&&x){let C=e.Ri??i.N,_={mode:h?\"floating\":\"sidebar\",legend:e.F,title:e.s??void 0,sidebarGutter:h?void 0:t.legendRect?.width,opacity:e.t.legend_opacity};if(e.k&&e.a.size>0){let v=he(i.Ne,C,Math.max(1,e.a.size));Ft(n,x,e.a,v,i,_),y=!0}else e.s&&($e(n,h?x:{x:x.x,y:x.y+20,width:x.width,height:x.height-20},{min:e.p,max:e.c,label:e.s},C,i,e.getColumnFormatter(e.s,\"value\"),_),y=!0)}if(y||e.F.clearPainted(),e.de>=0&&e.$&&e.j){let C=isNaN(e.S)?0:e.S,_=isNaN(e.D)?0:e.D,v=e.$[e.de]+C,A=e.j[e.de]+_,L=Hf(e,e.de),T=e.glyph.tooltipOptions(),w=xa(e,T),M=ie(e.t),I=e.U.grid??[];for(let D=0;D<t.cells.length;D++){let S=t.cells[D],E=D===L,k=S.layout.R(v,A),W=S.layout.e;if(k.px<W.x||k.px>W.x+W.width||k.py<W.y||k.py>W.y+W.height)continue;E&&w&&Ye(n,S.layout,i,o,ya(e,S.layout,k,v,A),M.opacity);let V=e.W.coordinated_tooltip;He(n,k,E||V?I:[],S.layout,i,o,{...M,crosshair:T.crosshair&&(!E||!w),highlightRadius:E?T.highlightRadius:0})}}}function Hf(e,t){return e.M<=0?0:Math.floor(t/e.M)}function ha(e,t,n,i,o){if(!e.Ut||!e.$||!e.j)return;let r=e.Ut.dictionary,s=e.Ut.data,l=e.$,a=e.j,u=isNaN(e.S)?0:e.S,m=isNaN(e.D)?0:e.D,f=e.M;if(f<=0)return;let c=0;for(let y=i;y<o;y++)c+=e.X[y]??0;if(c===0)return;let d=e.i?.dpr??1,b=le(t,d);if(!b)return;let g=e.v(),h=n.e,x=Math.max(1,Math.ceil(c/Vf));b.save(),b.font=`11px ${g.fontFamily}`,b.fillStyle=g.Fe,b.textAlign=\"left\",b.textBaseline=\"middle\";for(let y=i;y<o;y++){let C=e.X[y]??0,_=y*f;for(let v=0;v<C;v+=x){let A=_+v,L=s[A];if(L<0)continue;let{px:T,py:w}=n.R(l[A]+u,a[A]+m);T<h.x||T>h.x+h.width||w<h.y||w>h.y+h.height||b.fillText(r[L],T+8,w-4)}}b.restore()}function zf(e,t,n){let i=e.de;if(i<0||!e.$||!e.j)return;let o=isNaN(e.S)?0:e.S,r=isNaN(e.D)?0:e.D,s=e.$[i]+o,l=e.j[i]+r,a=n.R(s,l),u=e.U.grid??[],m=e.v(),f=e.i?.dpr??1,c=e.glyph.tooltipOptions(),d=xa(e,c);d&&Ye(t,n,m,f,ya(e,n,a,s,l),e.t.tooltip_opacity),He(t,a,u,n,m,f,{...ie(e.t),crosshair:c.crosshair&&!d,highlightRadius:c.highlightRadius})}function xa(e,t){return t.axisIndicators&&(e.Ht!==\"map\"||!!e.t.numeric_axes)}function ya(e,t,n,i,o){let r,s,l=e.getColumnFormatter(e.Ze,\"tick\"),a=e.getColumnFormatter(e.Ve,\"tick\");if(e.Ht===\"map\"){let u=Gn(t),[m,f]=Zt(i,o);r=l?l(m):u.formatX(i),s=a?a(f):u.formatY(o)}else{let u=l??fe(e.le?.isDate,e.kn),m=a??fe(e.te?.isDate,e.ae);r=u(i),s=m(o)}return[{side:\"bottom\",px:n.px,py:n.py,text:r},{side:\"left\",px:n.px,py:n.py,text:s}]}var Vf,Kr=G(()=>{\"use strict\";ji();ot();Ht();Rn();ge();Fn();Vt();Nt();be();Dn();Hr();Tt();ia();Bn();Ce();Jt();Nn();Ve();Vf=5e3});function Yf(e){if(!e.pn.isDirty||!e.$||!e.j)return;let t=e.$,n=e.j,i=Math.max(1,e.T.length),o=e.M,r=isNaN(e.S)?0:e.S,s=isNaN(e.D)?0:e.D;e.pn.rebuild({xMin:e.Ce-r,xMax:e.rt-r,yMin:e.Se-s,yMax:e.st-s},e.At,l=>{for(let a=0;a<i;a++){let u=e.X[a]??0,m=a*o;for(let f=0;f<u;f++)l(m+f,t[m+f],n[m+f])}})}function Jr(e,t,n){if(!e.$||!e.j)return;let{layout:i,facetIdx:o}=Xf(e,t,n);if(!i){_a(e);return}let r=i.e;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){_a(e);return}let s=i.O,l=i.Z,a=i.q,u=i.ee,m=s+(t-r.x)/r.width*(l-s),f=u-(n-r.y)/r.height*(u-a),c=r.width/(l-s),d=r.height/(u-a),b=isNaN(e.S)?0:e.S,g=isNaN(e.D)?0:e.D,h=m-b,x=f-g,y=o<0?$f(e,h,x,c,d):jf(e,o,h,x,c,d);if(y!==e.de||o!==e.Nn){if(e.de=y,e.Nn=o,y>=0){let C=e.U.beginHover(y);e.glyph.buildTooltipLines(e,y).then(_=>{e.U.commitHover(C,_)&&je(e)})}else e.U.clearHover();je(e)}}function _a(e){(e.de!==-1||e.Nn!==-1)&&(e.de=-1,e.Nn=-1,je(e))}function Xf(e,t,n){if(e.b){let i=e.b.cells;for(let o=0;o<i.length;o++){let r=i[o].layout.e;if(t>=r.x&&t<=r.x+r.width&&n>=r.y&&n<=r.y+r.height)return{layout:i[o].layout,facetIdx:o}}return{layout:null,facetIdx:-1}}return{layout:e.u,facetIdx:-1}}function $f(e,t,n,i,o){Yf(e);let r=e.pn.query(t,n,Un,i,o,e.$,e.j);if(r>=0)return r;let s=Un*Un,l=Math.max(1,e.T.length),a=e.M,u=e.$,m=e.j;for(let f=0;f<l;f++){let c=e.X[f]??0,d=f*a;for(let b=0;b<c;b++){let g=d+b,h=(u[g]-t)*i,x=(m[g]-n)*o,y=h*h+x*x;y<s&&(s=y,r=g)}}return r}function jf(e,t,n,i,o,r){let s=e.X[t]??0;if(s===0)return-1;let l=e.M,a=t*l,u=e.$,m=e.j,f=Un*Un,c=-1;for(let d=0;d<s;d++){let b=a+d,g=(u[b]-n)*o,h=(m[b]-i)*r,x=g*g+h*h;x<f&&(f=x,c=b)}return c}function Ca(e,t){if(e.w.dismiss(),e.uo=t,t<0||!e.$||!e.j)return;let n=Zf(e,t);if(!n)return;let i=isNaN(e.S)?0:e.S,o=isNaN(e.D)?0:e.D,r=n.R(e.$[t]+i,e.j[t]+o),s=e.U.beginPin();e.glyph.buildTooltipLines(e,t).then(l=>{e.U.isPinFresh(s)&&e.uo===t&&l.length!==0&&e.w.pin(l,r,n,ie(e.t))}),e.de=-1,e.Nn=-1,je(e)}function Zf(e,t){if(e.b&&e.M>0){let n=Math.floor(t/e.M),i=e.b.cells[n];if(i)return i.layout}return e.u}function va(e){e.w.dismiss(),e.uo=-1}var Un,Aa=G(()=>{\"use strict\";Kr();be();Un=24});var en,Qr=G(()=>{\"use strict\";en=class{constructor(){p(this,\"grid\",null);p(this,\"hoveredTarget\",null);p(this,\"mo\",0);p(this,\"fo\",0)}beginHover(t){return this.grid=null,this.hoveredTarget=t,++this.mo}commitHover(t,n){return t!==this.mo?!1:(this.grid=n,!0)}clearHover(){this.grid=null,this.hoveredTarget=null,this.mo++}beginPin(){return++this.fo}isPinFresh(t){return t===this.fo}invalidatePin(){this.fo++}}});function j(e,t,n,i,o,r){let s=e.shaders.getOrCreate(t,n,i),l=e.gl,a={program:s};for(let u of o)a[u]=l.getUniformLocation(s,u);for(let u of r)a[u]=l.getAttribLocation(s,u);return a}var de=G(()=>{\"use strict\"});async function mo(e,t){let n=[];if(!e.Ot||!e.Oe)return n;let i=e.Ot[t];if(i<0)return n;if(e.T.length>0&&e.M>0){let s=Math.floor(t/e.M),l=e.T[s];l?.prefix&&n.push([l.prefix])}let o=await e.Oe.fetchRow(i),r=e.T.length>0&&e.M>0?e.T[Math.floor(t/e.M)]?.prefix??null:null;for(let[s,l]of o){if(l==null)continue;let a=s;if(r!==null){let u=`${r}|`;if(!s.startsWith(u))continue;a=s.substring(u.length)}else if(s.includes(\"|\"))continue;if(typeof l==\"number\"){let u=e.getColumnFormatter(s,\"value\")(l);n.push([a,u])}else n.push([a,String(l)])}return n}var es=G(()=>{\"use strict\"});function qf(e,t,n,i,o){if(t.uniformMatrix4fv(e.u_projection,!1,n),t.uniform1f(e.u_point_size,i.t.point_size_px*o),i.p>=i.c)t.uniform2f(e.u_color_range,0,0);else if(i.s&&!i.k){let[s,l]=Hi(i.p,i.c);t.uniform2f(e.u_color_range,s,l)}else t.uniform2f(e.u_color_range,i.p,i.c);i.lt<i.ut?t.uniform2f(e.u_size_range,i.lt,i.ut):t.uniform2f(e.u_size_range,0,0);let r=Math.min(i.t.point_size_px,3);t.uniform2f(e.u_point_size_range,Math.max(2*o,i.t.point_size_px/r*o),i.t.point_size_px*r*o)}function La(e,t,n,i){let o=n.gl;if(!t.se)return!1;o.useProgram(e.program),qf(e,o,i,t,n.dpr),ze(n,t.se.texture,e.u_gradient_lut,0);let r=n.A.peek(\"a_position\"),s=n.A.peek(\"a_color_value\"),l=n.A.peek(\"a_size_value\");return!r||!s||!l?!1:(o.bindBuffer(o.ARRAY_BUFFER,r.buffer),o.enableVertexAttribArray(e.a_position),o.vertexAttribPointer(e.a_position,2,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,s.buffer),o.enableVertexAttribArray(e.a_color_value),o.vertexAttribPointer(e.a_color_value,1,o.FLOAT,!1,0,0),o.bindBuffer(o.ARRAY_BUFFER,l.buffer),o.enableVertexAttribArray(e.a_size_value),o.vertexAttribPointer(e.a_size_value,1,o.FLOAT,!1,0,0),!0)}var tn,ts=G(()=>{\"use strict\";Vt();ge();de();es();gr();hr();tn=class{constructor(){p(this,\"name\",\"point\");p(this,\"g\",null)}ensureProgram(t,n){this.g||(this.g=j(n,\"scatter\",li,ai,[\"u_projection\",\"u_point_size\",\"u_color_range\",\"u_gradient_lut\",\"u_size_range\",\"u_point_size_range\"],[\"a_position\",\"a_color_value\",\"a_size_value\"]))}draw(t,n,i){let o=this.g;if(!o||!La(o,t,n,i))return;let r=n.gl,s=Math.max(1,t.T.length),l=t.M;for(let a=0;a<s;a++){let u=t.X[a]??0;u<=0||r.drawArrays(r.POINTS,a*l,u)}}drawSeries(t,n,i,o){let r=this.g;if(!r||!La(r,t,n,i))return;let s=t.X[o]??0;if(s<=0)return;let l=n.gl,a=t.M;l.drawArrays(l.POINTS,o*a,s)}buildTooltipLines(t,n){return mo(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:6,axisIndicators:!0}}destroy(t){this.g=null}}});function Q(e){let t=e.gl;if(e.isWebGL2){let i=t;return{setDivisor(o,r){o<0||i.vertexAttribDivisor(o,r)},drawArraysInstanced(o,r,s,l){i.drawArraysInstanced(o,r,s,l)}}}let n=t.getExtension(\"ANGLE_instanced_arrays\");return{setDivisor(i,o){i<0||n?.vertexAttribDivisorANGLE(i,o)},drawArraysInstanced(i,o,r,s){n?.drawArraysInstancedANGLE(i,o,r,s)}}}function at(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,1,2,3]),e.STATIC_DRAW),t}function fo(e){let t=e.createBuffer();return e.bindBuffer(e.ARRAY_BUFFER,t),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),e.STATIC_DRAW),t}function ut(e,t,n,i,o,r=0){if(n<0)return!0;let s=e.A.peek(i);if(!s)return!1;let l=e.gl;return l.bindBuffer(l.ARRAY_BUFFER,s.buffer),l.enableVertexAttribArray(n),l.vertexAttribPointer(n,o,l.FLOAT,!1,0,r*o*Float32Array.BYTES_PER_ELEMENT),t.setDivisor(n,1),!0}var Be=G(()=>{\"use strict\"});function Ta(e,t,n,i){let o=n.gl;if(!t.se)return!1;let r=n.dpr;if(o.useProgram(e.program),o.uniformMatrix4fv(e.u_projection,!1,i),o.uniform2f(e.u_resolution,o.canvas.width,o.canvas.height),o.uniform1f(e.u_line_width,t.t.line_width_px*r),t.p>=t.c)o.uniform2f(e.u_color_range,0,0);else if(t.s&&!t.k){let[a,u]=Hi(t.p,t.c);o.uniform2f(e.u_color_range,a,u)}else o.uniform2f(e.u_color_range,t.p,t.c);ze(n,t.se.texture,e.u_gradient_lut,0);let s=Q(n),{setDivisor:l}=s;return o.bindBuffer(o.ARRAY_BUFFER,e.cornerBuffer),o.enableVertexAttribArray(e.a_corner),o.vertexAttribPointer(e.a_corner,1,o.FLOAT,!1,0,0),l(e.a_corner,0),o.enableVertexAttribArray(e.a_start),l(e.a_start,1),o.enableVertexAttribArray(e.a_end),l(e.a_end,1),o.enableVertexAttribArray(e.a_color_start),l(e.a_color_start,1),o.enableVertexAttribArray(e.a_color_end),l(e.a_color_end,1),!0}function wa(e,t,n,i){let o=t.X[i]??0;if(o<2)return;let r=n.gl,s=t.M,l=2*Float32Array.BYTES_PER_ELEMENT,a=Float32Array.BYTES_PER_ELEMENT,u=n.A.peek(\"a_position\"),m=n.A.peek(\"a_color_value\");if(!u||!m)return;let f=i*s*l;r.bindBuffer(r.ARRAY_BUFFER,u.buffer),r.vertexAttribPointer(e.a_start,2,r.FLOAT,!1,l,f),r.vertexAttribPointer(e.a_end,2,r.FLOAT,!1,l,f+l);let c=i*s*a;r.bindBuffer(r.ARRAY_BUFFER,m.buffer),r.vertexAttribPointer(e.a_color_start,1,r.FLOAT,!1,a,c),r.vertexAttribPointer(e.a_color_end,1,r.FLOAT,!1,a,c+a),Q(n).drawArraysInstanced(r.TRIANGLE_STRIP,0,4,o-1)}function Ma(e,t){let{setDivisor:n}=Q(t);n(e.a_start,0),n(e.a_end,0),n(e.a_color_start,0),n(e.a_color_end,0)}var nn,ns=G(()=>{\"use strict\";Vt();Be();de();ge();Ce();pr();br();nn=class{constructor(){p(this,\"name\",\"line\");p(this,\"g\",null)}ensureProgram(t,n){if(this.g)return;let i=j(n,\"line\",ri,si,[\"u_projection\",\"u_resolution\",\"u_line_width\",\"u_color_range\",\"u_gradient_lut\"],[\"a_start\",\"a_end\",\"a_color_start\",\"a_color_end\",\"a_corner\"]);this.g={...i,cornerBuffer:at(n.gl)}}draw(t,n,i){let o=this.g;if(!o||!Ta(o,t,n,i))return;let s=Math.max(1,t.T.length);for(let l=0;l<s;l++)wa(o,t,n,l);Ma(o,n)}drawSeries(t,n,i,o){let r=this.g;r&&Ta(r,t,n,i)&&(wa(r,t,n,o),Ma(r,n))}async buildTooltipLines(t,n){let i=[];if(!t.$||!t.j)return i;if(t.T.length>0&&t.M>0){let c=Math.floor(n/t.M),d=t.T[c];d&&i.push([d.prefix])}let o=t.$[n],r=t.j[n],s=t.je[t.Ue]||\"\",a=s===\"date\"||s===\"datetime\"?Yt(o):Ee(o);i.push([t.Ue||\"Row\",a]);let u=t.je[t.De]||\"\",f=u===\"date\"||u===\"datetime\"?Yt(r):Ee(r);return i.push([t.De,f]),i}tooltipOptions(){return{crosshair:!0,highlightRadius:5,axisIndicators:!0}}destroy(t){let n=this.g;n?.cornerBuffer&&t.i&&t.i.gl.deleteBuffer(n.cornerBuffer),this.g=null}}});function tc(e){switch(e){case\"density\":return Kf;case\"extreme\":return Qf;case\"signed\":return ec;case\"mean\":default:return Jf}}function Ra(e){let t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),t}function is(e,t,n,i){return j(e,t,n,i,[\"u_projection\",\"u_radius_ndc\",\"u_intensity\",\"u_color_range\"],[\"a_corner\",\"a_position\",\"a_color_value\"])}function nc(e){let t=e.gl;if(e.isWebGL2){let n=t;if(n.getExtension(\"EXT_color_buffer_float\"))return{internalFormat:n.RGBA16F,format:n.RGBA,type:n.HALF_FLOAT,isFloat:!0}}return{internalFormat:t.RGBA,format:t.RGBA,type:t.UNSIGNED_BYTE,isFloat:!1}}function Fa(e){let t=e.A.peek(\"a_position\"),n=e.A.peek(\"a_color_value\");return!!t&&!!n}function oc(e,t){if(!e.s||e.k)return t.robustBounds=null,null;let n=t.robustBounds;if(n&&n.dataCount===e.At&&n.colorName===e.s&&n.colorIsString===e.k)return{lo:n.lo,hi:n.hi};let i=rc(e);return i?(t.robustBounds={lo:i.lo,hi:i.hi,dataCount:e.At,colorName:e.s,colorIsString:e.k},i):(t.robustBounds=null,null)}function rc(e){if(!e.Lt||e.At<2)return null;let t=e.M,n=Math.max(1,e.T.length),i=Math.max(1,Math.ceil(e.At/ic)),o=[],r=e.Lt;for(let m=0;m<n;m++){let f=e.X[m]??0,c=m*t;for(let d=0;d<f;d+=i){let b=r[c+d];Number.isFinite(b)&&o.push(b)}}if(o.length<2)return null;o.sort((m,f)=>m-f);let s=Math.floor(o.length*.05),l=Math.min(o.length-1,Math.ceil(o.length*.95)),a=o[s],u=o[l];return u>a?{lo:a,hi:u}:e.c>e.p?{lo:e.p,hi:e.c}:null}var Kf,Jf,Qf,ec,on,ic,os=G(()=>{\"use strict\";Vt();Be();de();es();xr();yr();_r();js();qs();Cr();vr();Kf=0,Jf=1,Qf=2,ec=3,on=class{constructor(){p(this,\"name\",\"density\");p(this,\"g\",null)}ensureProgram(t,n){if(this.g){this.ensureHeatTarget(t,n);return}let i=n.gl,o=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,o),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),i.STATIC_DRAW);let r=i.createBuffer();i.bindBuffer(i.ARRAY_BUFFER,r),i.bufferData(i.ARRAY_BUFFER,new Float32Array([-1,-1,3,-1,-1,3]),i.STATIC_DRAW);let{internalFormat:s,format:l,type:a,isFloat:u}=nc(n),m=Ra(i),f=i.createFramebuffer();this.g={splat:is(n,\"density-splat\",Wt,Ci),extremeSplat:null,mrtSplat:null,resolve:j(n,\"density-resolve\",Ai,Li,[\"u_heat\",\"u_extreme\",\"u_gradient_lut\",\"u_heat_max\",\"u_color_mode\"],[\"a_corner\"]),quadCornerBuffer:o,tripleCornerBuffer:r,heatTexture:m,heatFramebuffer:f,extremeTexture:null,extremeFramebuffer:null,mrtFramebuffer:null,heatWidth:0,heatHeight:0,heatType:a,heatInternalFormat:s,heatFormat:l,floatFbo:u,indexedBlend:null,signedDowngradeWarned:!1,robustBounds:null},this.ensureHeatTarget(t,n)}draw(t,n,i){let o=this.g;if(!o||!Fa(n))return;let r=Math.max(1,t.T.length),s=t.M,l=0;for(let a=0;a<r;a++)l+=t.X[a]??0;l!==0&&this.runSplatAndResolve(t,n,o,i,a=>{for(let u=0;u<r;u++){let m=t.X[u]??0;m<=0||a(u*s,m)}})}drawSeries(t,n,i,o){let r=this.g;if(!r||!Fa(n))return;let s=t.X[o]??0;if(s<=0)return;let l=t.M;this.runSplatAndResolve(t,n,r,i,a=>a(o*l,s))}buildTooltipLines(t,n){return mo(t,n)}tooltipOptions(){return{crosshair:!0,highlightRadius:0,axisIndicators:!0}}destroy(t){let n=this.g;if(!n||!t.i){this.g=null;return}let i=t.i.gl;i.deleteBuffer(n.quadCornerBuffer),i.deleteBuffer(n.tripleCornerBuffer),i.deleteTexture(n.heatTexture),i.deleteFramebuffer(n.heatFramebuffer),n.extremeTexture&&i.deleteTexture(n.extremeTexture),n.extremeFramebuffer&&i.deleteFramebuffer(n.extremeFramebuffer),n.mrtFramebuffer&&i.deleteFramebuffer(n.mrtFramebuffer),this.g=null}ensureHeatTarget(t,n){let i=this.g;if(!i)return;let o=n.gl,r=o.canvas.width,s=o.canvas.height;if(!(r===i.heatWidth&&s===i.heatHeight)&&!(r<=0||s<=0)){if(this.allocAccumTexture(o,i,i.heatTexture,r,s),o.bindFramebuffer(o.FRAMEBUFFER,i.heatFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i.heatTexture,0),i.extremeTexture&&(this.allocAccumTexture(o,i,i.extremeTexture,r,s),i.extremeFramebuffer&&(o.bindFramebuffer(o.FRAMEBUFFER,i.extremeFramebuffer),o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_2D,i.extremeTexture,0)),i.mrtFramebuffer)){let l=o;l.bindFramebuffer(l.FRAMEBUFFER,i.mrtFramebuffer),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,i.heatTexture,0),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT1,l.TEXTURE_2D,i.extremeTexture,0)}o.bindFramebuffer(o.FRAMEBUFFER,null),i.heatWidth=r,i.heatHeight=s}}allocAccumTexture(t,n,i,o,r){t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,n.heatInternalFormat,o,r,0,n.heatFormat,n.heatType,null)}ensureExtremeTarget(t,n){let i=t.gl;if(n.extremeTexture)return;let o=Ra(i);if(n.extremeTexture=o,n.extremeFramebuffer=i.createFramebuffer(),this.allocAccumTexture(i,n,o,n.heatWidth,n.heatHeight),i.bindFramebuffer(i.FRAMEBUFFER,n.extremeFramebuffer),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,o,0),n.indexedBlend===null){let r=t.isWebGL2?i.getExtension(\"OES_draw_buffers_indexed\"):null;n.indexedBlend=r??!1}if(n.indexedBlend){let r=i;n.mrtFramebuffer=r.createFramebuffer(),r.bindFramebuffer(r.FRAMEBUFFER,n.mrtFramebuffer),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,n.heatTexture,0),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT1,r.TEXTURE_2D,o,0)}i.bindFramebuffer(i.FRAMEBUFFER,null)}ensureExtremeSplatProgram(t,n){return n.extremeSplat||(n.extremeSplat=is(t,\"density-extreme\",Wt,vi)),n.extremeSplat}ensureMrtSplatProgram(t,n){return n.mrtSplat||(n.mrtSplat=is(t,\"density-mrt\",Zs,Ks)),n.mrtSplat}activeMode(t,n,i){let o=n.t.gradient_color_mode;return o===\"signed\"&&!i.floatFbo?(this.warnDowngradeOnce(i,\"signed mode requires a float framebuffer (EXT_color_buffer_float); falling back to mean.\"),\"mean\"):o===\"extreme\"&&!t.isWebGL2?(this.warnDowngradeOnce(i,\"extreme mode requires WebGL2 (for MAX blend and a second color attachment); falling back to mean.\"),\"mean\"):o}warnDowngradeOnce(t,n){t.signedDowngradeWarned||(t.signedDowngradeWarned=!0,console.warn(`Density: ${n}`))}runSplatAndResolve(t,n,i,o,r){if(this.ensureHeatTarget(t,n),i.heatWidth===0||i.heatHeight===0||!t.se)return;let s=this.activeMode(n,t,i),l=t.p<t.c&&(!!t.s||t.T.length>1),a=0,u=0;if(s!==\"density\"&&l&&(a=t.p,u=t.c,!t.k&&(s===\"mean\"||s===\"extreme\"))){let f=oc(t,i);f&&(a=f.lo,u=f.hi)}s===\"extreme\"&&this.ensureExtremeTarget(n,i),s===\"extreme\"&&i.indexedBlend?this.runMrtExtremePass(n,i,o,t.t.gradient_intensity,n.dpr*t.t.gradient_radius_px,a,u,r):(this.runHeatPass(n,i,o,t.t.gradient_intensity,n.dpr*t.t.gradient_radius_px,a,u,r),s===\"extreme\"&&this.runExtremePass(n,i,o,t.t.gradient_intensity,n.dpr*t.t.gradient_radius_px,a,u,r)),this.runResolvePass(n,i,t,s)}runHeatPass(t,n,i,o,r,s,l,a){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST);u.bindFramebuffer(u.FRAMEBUFFER,n.heatFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE),u.blendEquation(u.FUNC_ADD),this.bindSplatProgram(u,n.splat,i,o,r,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,n.splat,a),this.unbindSplatInstancing(t,n.splat)}runExtremePass(t,n,i,o,r,s,l,a){let u=t.gl,m=!!u.getParameter(u.SCISSOR_TEST),f=this.ensureExtremeSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.extremeFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),this.clearTarget(u,m),u.blendFunc(u.ONE,u.ONE);let c=u;c.blendEquation(c.MAX),this.bindSplatProgram(u,f,i,o,r,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,f,a),this.unbindSplatInstancing(t,f),u.blendEquation(u.FUNC_ADD)}runMrtExtremePass(t,n,i,o,r,s,l,a){let u=t.gl,m=n.indexedBlend,f=!!u.getParameter(u.SCISSOR_TEST),c=this.ensureMrtSplatProgram(t,n);u.bindFramebuffer(u.FRAMEBUFFER,n.mrtFramebuffer),u.viewport(0,0,n.heatWidth,n.heatHeight),u.drawBuffers([u.COLOR_ATTACHMENT0,u.COLOR_ATTACHMENT1]),this.clearTarget(u,f),m.enableiOES(u.BLEND,0),m.enableiOES(u.BLEND,1),m.blendEquationiOES(0,u.FUNC_ADD),m.blendFunciOES(0,u.ONE,u.ONE),m.blendEquationiOES(1,u.MAX),m.blendFunciOES(1,u.ONE,u.ONE),this.bindSplatProgram(u,c,i,o,r,n.heatWidth,n.heatHeight,s,l),this.bindAndDispatchInstanced(t,n,c,a),this.unbindSplatInstancing(t,c),m.blendEquationiOES(0,u.FUNC_ADD),m.blendEquationiOES(1,u.FUNC_ADD),m.blendFunciOES(0,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),m.blendFunciOES(1,u.SRC_ALPHA,u.ONE_MINUS_SRC_ALPHA),u.drawBuffers([u.COLOR_ATTACHMENT0])}clearTarget(t,n){n&&t.disable(t.SCISSOR_TEST),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),n&&t.enable(t.SCISSOR_TEST)}bindSplatProgram(t,n,i,o,r,s,l,a,u){t.useProgram(n.program),t.uniformMatrix4fv(n.u_projection,!1,i),t.uniform1f(n.u_intensity,o);let m=2*r/Math.max(1,s),f=2*r/Math.max(1,l);t.uniform2f(n.u_radius_ndc,m,f),t.uniform2f(n.u_color_range,a,u)}bindAndDispatchInstanced(t,n,i,o){let r=t.gl;r.bindBuffer(r.ARRAY_BUFFER,n.quadCornerBuffer),r.enableVertexAttribArray(i.a_corner),r.vertexAttribPointer(i.a_corner,2,r.FLOAT,!1,0,0);let s=Q(t);s.setDivisor(i.a_corner,0),s.setDivisor(i.a_position,1),s.setDivisor(i.a_color_value,1);let l=t.A.peek(\"a_position\"),a=t.A.peek(\"a_color_value\");o((u,m)=>{let f=2*Float32Array.BYTES_PER_ELEMENT,c=Float32Array.BYTES_PER_ELEMENT;r.bindBuffer(r.ARRAY_BUFFER,l.buffer),r.enableVertexAttribArray(i.a_position),r.vertexAttribPointer(i.a_position,2,r.FLOAT,!1,f,u*f),r.bindBuffer(r.ARRAY_BUFFER,a.buffer),r.enableVertexAttribArray(i.a_color_value),r.vertexAttribPointer(i.a_color_value,1,r.FLOAT,!1,c,u*c),s.drawArraysInstanced(r.TRIANGLE_STRIP,0,4,m)})}unbindSplatInstancing(t,n){let i=Q(t);i.setDivisor(n.a_position,0),i.setDivisor(n.a_color_value,0)}runResolvePass(t,n,i,o){let r=t.gl;r.bindFramebuffer(r.FRAMEBUFFER,null),r.viewport(0,0,r.canvas.width,r.canvas.height),r.blendEquation(r.FUNC_ADD),r.blendFunc(r.SRC_ALPHA,r.ONE_MINUS_SRC_ALPHA);let s=n.resolve;r.useProgram(s.program),r.uniform1f(s.u_heat_max,i.t.gradient_heat_max),r.uniform1i(s.u_color_mode,tc(o)),r.activeTexture(r.TEXTURE0),r.bindTexture(r.TEXTURE_2D,n.heatTexture),r.uniform1i(s.u_heat,0),r.activeTexture(r.TEXTURE1),r.bindTexture(r.TEXTURE_2D,n.extremeTexture??n.heatTexture),r.uniform1i(s.u_extreme,1),ze(t,i.se.texture,s.u_gradient_lut,2),r.bindBuffer(r.ARRAY_BUFFER,n.tripleCornerBuffer),r.enableVertexAttribArray(s.a_corner),r.vertexAttribPointer(s.a_corner,2,r.FLOAT,!1,0,0),r.drawArrays(r.TRIANGLES,0,3)}};ic=5e4});var St,co,po,bo,rs=G(()=>{\"use strict\";Ln();kl();Vl();Kr();Aa();Qr();ts();ns();os();St=class extends De{constructor(n){super();p(this,\"glyph\");p(this,\"Ht\",\"cartesian\");p(this,\"se\",null);p(this,\"Ze\",\"\");p(this,\"Ve\",\"\");p(this,\"Ue\",\"\");p(this,\"De\",\"\");p(this,\"nr\",!1);p(this,\"s\",\"\");p(this,\"re\",\"\");p(this,\"wi\",\"\");p(this,\"k\",!1);p(this,\"He\",!1);p(this,\"ve\",!1);p(this,\"bn\",[]);p(this,\"gn\",[]);p(this,\"ir\",new Map);p(this,\"or\",new Map);p(this,\"mt\",null);p(this,\"ft\",null);p(this,\"T\",[]);p(this,\"Ce\",1/0);p(this,\"rt\",-1/0);p(this,\"Se\",1/0);p(this,\"st\",-1/0);p(this,\"S\",NaN);p(this,\"D\",NaN);p(this,\"p\",1/0);p(this,\"c\",-1/0);p(this,\"lt\",1/0);p(this,\"ut\",-1/0);p(this,\"Pn\",1/0);p(this,\"Bn\",-1/0);p(this,\"Gn\",1/0);p(this,\"Wn\",-1/0);p(this,\"vi\",1/0);p(this,\"Ai\",-1/0);p(this,\"Li\",1/0);p(this,\"Ti\",-1/0);p(this,\"M\",0);p(this,\"X\",[]);p(this,\"no\",0);p(this,\"$\",null);p(this,\"j\",null);p(this,\"Lt\",null);p(this,\"Ot\",null);p(this,\"Ut\",null);p(this,\"At\",0);p(this,\"a\",new Map);p(this,\"U\",new en);p(this,\"io\",null);p(this,\"oo\",null);p(this,\"ro\",null);p(this,\"rr\",0);p(this,\"pn\",new Xi);p(this,\"u\",null);p(this,\"de\",-1);p(this,\"uo\",-1);p(this,\"Nn\",-1);p(this,\"b\",null);p(this,\"le\",null);p(this,\"te\",null);p(this,\"kn\",null);p(this,\"ae\",null);p(this,\"Ri\",null);p(this,\"Fi\",!1);p(this,\"Mi\",null);p(this,\"so\",null);p(this,\"ao\",-1);this.glyph=n}colorScaleColumn(){return this.s||null}repaintChrome(){je(this)}projectPoint(n,i){return[n,i]}renderBackground(n,i,o,r,s,l){}renderMapChrome(n,i,o,r){}tooltipCallbacks(){return{onHover:(n,i)=>Jr(this,n,i),onLeave:()=>{this.de!==-1&&(this.de=-1,je(this))},onPin:(n,i)=>{if(Jr(this,n,i),this.de>=0){let o=this.de;Ca(this,o),this.Dr(o)}},onUnpin:()=>{this.emitUnselect()}}}async Dr(n){if(!this.Ot)return;let i=this.Ot[n],o=this.L[1]||this.L[0]||\"\",r=[];if(this.T.length>0&&this.M>0){let s=Math.floor(n/this.M),l=this.T[s];l?.prefix&&this.B.length>0&&(r=l.prefix.split(\"|\"))}await this.emitClickAndSelect({rowIdx:i!=null&&i>=0?i:null,columnName:o,groupByValues:[],splitByValues:r})}async uploadAndRender(n,i,o,r){let s=r-o;this.i=n,o===0&&Ul(this,n,i,r),s!==0&&(Hl(this,n,i,o,s,r),this.t.domain_mode===\"expand\"&&(this.He||(this.Pn=this.Ce,this.Bn=this.rt),this.ve||(this.Gn=this.Se,this.Wn=this.st),this.vi=this.p,this.Ai=this.c,this.Li=this.lt,this.Ti=this.ut),await this.requestRender(n))}resetExpandedDomain(){this.Pn=1/0,this.Bn=-1/0,this.Gn=1/0,this.Wn=-1/0,this.vi=1/0,this.Ai=-1/0,this.Li=1/0,this.Ti=-1/0}kt(n){n.uploadedCount===0&&this.At===0||(this.i=n,ga(this,n))}destroyInternal(){this.glyph.destroy(this),this.se=null,this.$=null,this.j=null,this.Lt=null,this.Ot=null,this.Ut=null,this.U.clearHover(),this.a.clear(),this.pn.clear(),this.io=null,this.oo=null,this.ro=null,this.T=[],this.X=[],va(this)}},co=class extends St{constructor(){super(new tn)}},po=class extends St{constructor(){super(new nn)}},bo=class extends St{constructor(){super(new on)}}});var sr,Xu=G(()=>{\"use strict\";sr=class{constructor(t=256){p(this,\"Me\",new Map);p(this,\"gr\");this.gr=t}get(t){let n=this.Me.get(t);return n!==void 0&&(this.Me.delete(t),this.Me.set(t,n)),n}set(t,n,i){if(this.Me.has(n)){let o=this.Me.get(n);t.deleteTexture(o),this.Me.delete(n)}for(this.Me.set(n,i);this.Me.size>this.gr;){let o=this.Me.keys().next().value;if(o===void 0)break;let r=this.Me.get(o);t.deleteTexture(r),this.Me.delete(o)}}has(t){return this.Me.has(t)}dispose(t){for(let n of this.Me.values())t.deleteTexture(n);this.Me.clear()}}});function cn(e,t,n,i){return`${e}/${t}/${n}/${i}`}var lr,$u=G(()=>{\"use strict\";lr=class{constructor(){p(this,\"Re\",new Map);p(this,\"hr\",()=>{})}setOnLoad(t){this.hr=t}load(t,n,i,o){let r=cn(t.id,n,i,o),s=this.Re.get(r);if(s)return s.promise;let l=new AbortController,a=t.urlFor(n,i,o),u=this.Pr(a,l.signal).then(m=>(this.Re.delete(r),m&&this.hr(),m)).catch(()=>(this.Re.delete(r),null));return this.Re.set(r,{promise:u,abort:l}),u}cancelAll(){for(let t of this.Re.values())t.abort.abort();this.Re.clear()}cancelExcept(t){for(let[n,i]of this.Re)t.has(n)||(i.abort.abort(),this.Re.delete(n))}async Pr(t,n){let i=self.origin?.startsWith(\"http\")?`${self.origin}/`:void 0,o=await fetch(t,{signal:n,referrer:i});if(!o.ok)return null;let r=await o.blob();return await createImageBitmap(r)}}});var ar,ju=G(()=>{\"use strict\";Bn();Xu();$u();Ar();Lr();de();ar=class{constructor(){p(this,\"o\",null);p(this,\"H\",null);p(this,\"g\",new sr);p(this,\"ti\",new lr);p(this,\"ni\",null);p(this,\"xr\",1);p(this,\"yr\",()=>{})}setOnTileLoad(t){this.yr=t,this.ti.setOnLoad(t)}setSource(t,n){this.ni?.id!==n.id&&(this.g.dispose(t),this.ti.cancelAll(),this.ni=n)}setAlpha(t){this.xr=Math.max(0,Math.min(1,t))}get source(){return this.ni}render(t,n,i,o,r,s){let l=this.ni;if(!l)return;this.Br(t);let a=this.o,u=this.H;if(!a||!u)return;let m=t.gl,f=t.dpr,c=Math.max(1,n.e.width*f),d=o.xMax-o.xMin;if(!isFinite(d)||d<=0)return;let b=d/c,g=Kl(b,l.tileSize,l.maxZoom),h=Jl(o,g),x=new Set;for(let C of h)x.add(cn(l.id,C.z,C.x,C.y));this.ti.cancelExcept(x),m.useProgram(a.program),m.uniformMatrix4fv(a.u_projection,!1,i),m.uniform1f(a.u_alpha,this.xr),m.bindBuffer(m.ARRAY_BUFFER,u),m.enableVertexAttribArray(a.a_corner),m.vertexAttribPointer(a.a_corner,2,m.FLOAT,!1,0,0),m.activeTexture(m.TEXTURE0),m.uniform1i(a.u_tile,0);let y=m.isEnabled(m.BLEND);m.enable(m.BLEND),m.blendFunc(m.SRC_ALPHA,m.ONE_MINUS_SRC_ALPHA);for(let C of h)this.Gr(m,a,l,C,r,s);y||m.disable(m.BLEND)}destroy(t){this.ti.cancelAll(),this.g.dispose(t),this.H&&(t.deleteBuffer(this.H),this.H=null),this.o=null}Gr(t,n,i,o,r,s){let l=ql(o.z,o.x,o.y),a={xMin:l.xMin-r,xMax:l.xMax-r,yMin:l.yMin-s,yMax:l.yMax-s},u=cn(i.id,o.z,o.x,o.y),m=this.g.get(u);if(m){this._r(t,n,m,a,[0,0],[1,1]);return}this.Wr(t,i,o);for(let f=1;f<=6;f++){let c=o.z-f;if(c<0)return;let d=o.x>>f,b=o.y>>f,g=cn(i.id,c,d,b),h=this.g.get(g);if(!h)continue;let x=1<<f,y=o.x-d*x,C=o.y-b*x,_=1/x,v=[y*_,C*_],A=[v[0]+_,v[1]+_];this._r(t,n,h,a,v,A);return}}_r(t,n,i,o,r,s){t.bindTexture(t.TEXTURE_2D,i),t.uniform2f(n.u_extent_min,o.xMin,o.yMin),t.uniform2f(n.u_extent_max,o.xMax,o.yMax),t.uniform2f(n.u_uv_min,r[0],r[1]),t.uniform2f(n.u_uv_max,s[0],s[1]),t.drawArrays(t.TRIANGLE_STRIP,0,4)}Wr(t,n,i){let o=cn(n.id,i.z,i.x,i.y);this.g.has(o)||this.ti.load(n,i.z,i.x,i.y).then(r=>{if(!r)return;if(this.ni?.id!==n.id){r.close();return}let s=t.createTexture();if(!s){r.close();return}t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,s),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!1),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!1),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,r),this.g.set(t,o,s),this.yr()})}Br(t){if(this.o&&this.H)return;let n=t.gl;this.o=j(t,\"map-tile\",Ti,wi,[\"u_projection\",\"u_extent_min\",\"u_extent_max\",\"u_uv_min\",\"u_uv_max\",\"u_tile\",\"u_alpha\"],[\"a_corner\"]);let i=n.createBuffer();i&&(n.bindBuffer(n.ARRAY_BUFFER,i),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),this.H=i)}}});var ur={};fm(ur,{MapChart:()=>dn,MapDensityChart:()=>Us,MapLineChart:()=>Os,MapScatterChart:()=>Ns});var dn,Ns,Os,Us,mr=G(()=>{\"use strict\";rs();ts();ns();os();ju();Ei();Bn();Tt();dn=class extends St{constructor(n){super(n);p(this,\"Ht\",\"map\");p(this,\"it\");this.it=new ar,this.it.setOnTileLoad(()=>{this.i&&this.requestRender(this.i)})}projectPoint(n,i){return eo(n,i)}getZoomConfig(){return{lockAspect:!0}}setPluginConfig(n){super.setPluginConfig(n),this.i&&this.it.setSource(this.i.gl,et.sourceFor(n.map_tile_provider)),this.it.setAlpha(n.map_tile_alpha)}renderBackground(n,i,o,r,s,l){this.it.source||(this.it.setSource(n.gl,et.sourceFor(this.t.map_tile_provider)),this.it.setAlpha(this.t.map_tile_alpha)),this.it.render(n,i,o,r,s,l)}renderMapChrome(n,i,o,r){if(!n)return;let s=le(n,r);if(!s)return;let l=this.it.source?.attribution??\"\";if(!l)return;let a=i.e;s.save(),s.font=`10px ${o.fontFamily}`,s.textAlign=\"right\",s.textBaseline=\"bottom\";let u=4,f=s.measureText(l).width,c=12,d=a.x+a.width-4,b=a.y+a.height-4;s.fillStyle=\"rgba(255, 255, 255, 0.75)\",s.fillRect(d-f-u*2,b-c-u,f+u*2,c+u),s.fillStyle=o.Fe,s.fillText(l,d-u,b-u/2),s.restore()}destroyInternal(){this.i&&this.it.destroy(this.i.gl),super.destroyInternal()}},Ns=class extends dn{constructor(){super(new tn)}},Os=class extends dn{constructor(){super(new nn)}},Us=class extends dn{constructor(){super(new on)}}});typeof window>\"u\"&&(globalThis.window={});var xn=class{constructor(t){p(this,\"ht\");p(this,\"r\",new Map);p(this,\"Tn\",0);p(this,\"ii\",0);this.ht=t}get totalCapacity(){return this.Tn}get maxCapacity(){return this.ii}set maxCapacity(t){this.ii=t}ensureCapacity(t){this.Tn=this.ii>0?Math.min(t,this.ii):t}peek(t){return this.r.get(t)}getOrCreate(t,n,i){let o=this.Tn*n*i,r=this.r.get(t);if(r&&r.byteCapacity>=o)return r;let s=this.ht;r&&s.deleteBuffer(r.buffer);let l=s.createBuffer();return s.bindBuffer(s.ARRAY_BUFFER,l),s.bufferData(s.ARRAY_BUFFER,o,s.DYNAMIC_DRAW),r={buffer:l,byteCapacity:o},this.r.set(t,r),r}upload(t,n,i,o=1){let r=this.ht,s=this.getOrCreate(t,o,n.BYTES_PER_ELEMENT);if(!1){let l=i+n.byteLength;if(l>s.byteCapacity)throw new Error(`BufferPool.upload(\"${t}\"): write ${i}..${l} exceeds capacity ${s.byteCapacity} (_totalCapacity=${this.Tn}, components=${o}, bytes=${n.BYTES_PER_ELEMENT}). Did you pass the full scratch buffer instead of a subarray(0, n)?`)}return r.bindBuffer(r.ARRAY_BUFFER,s.buffer),r.bufferSubData(r.ARRAY_BUFFER,i,n),s.buffer}releaseAll(){for(let t of this.r.values())this.ht.deleteBuffer(t.buffer);this.r.clear(),this.Tn=0}};var yn=class{constructor(t){p(this,\"ht\");p(this,\"oi\",new Map);this.ht=t}precompile(t){for(let n of t)this.getOrCreate(n.name,n.vert,n.frag)}getOrCreate(t,n,i){let o=this.oi.get(t);if(o)return o;let r=this.ht,s=r.createShader(r.VERTEX_SHADER);if(r.shaderSource(s,n),r.compileShader(s),!r.getShaderParameter(s,r.COMPILE_STATUS)){let a=r.getShaderInfoLog(s);throw r.deleteShader(s),new Error(`Vertex shader compile error [${t}]: ${a}`)}let l=r.createShader(r.FRAGMENT_SHADER);if(r.shaderSource(l,i),r.compileShader(l),!r.getShaderParameter(l,r.COMPILE_STATUS)){let a=r.getShaderInfoLog(l);throw r.deleteShader(s),r.deleteShader(l),new Error(`Fragment shader compile error [${t}]: ${a}`)}if(o=r.createProgram(),r.attachShader(o,s),r.attachShader(o,l),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS)){let a=r.getProgramInfoLog(o);throw r.deleteProgram(o),r.deleteShader(s),r.deleteShader(l),new Error(`Shader link error [${t}]: ${a}`)}return r.deleteShader(s),r.deleteShader(l),this.oi.set(t,o),o}releaseAll(){for(let t of this.oi.values())this.ht.deleteProgram(t);this.oi.clear()}};var ii=\"attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;attribute float a_series_id;attribute float a_axis;uniform mat4 u_proj_left;uniform mat4 u_proj_right;uniform float u_hover_series;uniform float u_horizontal;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec2 A;if(u_horizontal>0.5){A=vec2(mix(a_y0,a_y1,a_corner.x),a_x_center+(a_corner.y-0.5)*2.*a_half_width);}else{A=vec2(a_x_center+(a_corner.x-0.5)*2.*a_half_width,mix(a_y0,a_y1,a_corner.y));}mat4 B=a_axis<0.5?u_proj_left:u_proj_right;gl_Position=B*vec4(A,0.,1.);v_color=a_color;v_hover=abs(a_series_id-u_hover_series)<0.5?1.:0.;v_local=a_corner;}\";var oi=\"precision highp float;varying vec3 v_color;varying float v_hover;varying vec2 v_local;void main(){vec3 A=v_color;if(v_hover>0.5){A=mix(A,vec3(1.),0.25);}gl_FragColor=vec4(A,1.);}\";pr();br();gr();hr();var ui=\"attribute vec2 a_position;uniform mat4 u_projection;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);}\";var mi=\"precision highp float;uniform vec3 u_color;uniform float u_opacity;void main(){gl_FragColor=vec4(u_color,u_opacity);}\";var Ke=\"attribute vec2 a_start;attribute vec2 a_end;attribute float a_corner;attribute float a_real_start;attribute float a_real_end;uniform mat4 u_projection;uniform vec2 u_resolution;uniform float u_line_width;uniform float u_interp_alpha;varying float v_edge_dist;varying float v_seg_alpha;void main(){vec4 A=u_projection*vec4(a_start,0.,1.);vec4 B=u_projection*vec4(a_end,0.,1.);vec2 C=A.xy*u_resolution*0.5;vec2 D=B.xy*u_resolution*0.5;vec2 E=D-C;float F=length(E);E=F>0.001?E/F:vec2(1.,0.);vec2 G=vec2(-E.y,E.x);float H=step(1.5,a_corner);float I=1.-mod(a_corner,2.)*2.;vec4 J=mix(A,B,H);float K=(u_line_width+1.5)*0.5;vec2 L=(G*I*K)/(u_resolution*0.5);gl_Position=J+vec4(L,0.,0.);v_edge_dist=I;float M=a_real_start*a_real_end;v_seg_alpha=mix(u_interp_alpha,1.,step(0.5,M));}\";var Je=\"precision highp float;uniform vec4 u_color;uniform float u_line_width;varying float v_edge_dist;varying float v_seg_alpha;void main(){float A=abs(v_edge_dist);float B=u_line_width/(u_line_width+1.5);float C=1.-smoothstep(B,1.,A);gl_FragColor=vec4(u_color.rgb,u_color.a*C*v_seg_alpha);}\";var fi=\"attribute vec2 a_position;attribute vec3 a_color;uniform mat4 u_projection;uniform float u_point_size;varying vec3 v_color;varying float v_point_size;void main(){gl_Position=u_projection*vec4(a_position,0.,1.);gl_PointSize=u_point_size;v_point_size=u_point_size;v_color=a_color;}\";var ci=\"precision highp float;varying vec3 v_color;varying float v_point_size;void main(){vec2 A=gl_PointCoord-vec2(0.5);float B=length(A);if(B>0.5)discard;float C=1.5/max(v_point_size,1.);float D=1.-smoothstep(0.5-C,0.5,B);gl_FragColor=vec4(v_color,D);}\";var di=\"attribute vec2 a_corner;attribute float a_x_center;attribute float a_half_width;attribute float a_y0;attribute float a_y1;attribute vec3 a_color;uniform mat4 u_projection;varying vec3 v_color;void main(){float A=a_x_center+(a_corner.x-0.5)*2.*a_half_width;float B=mix(a_y0,a_y1,a_corner.y);gl_Position=u_projection*vec4(A,B,0.,1.);v_color=a_color;}\";var pi=\"precision highp float;varying vec3 v_color;void main(){gl_FragColor=vec4(v_color,1.);}\";var bi=\"attribute vec2 a_corner;attribute vec2 a_cell;attribute float a_color_t;uniform mat4 u_projection;uniform vec2 u_cell_inset;uniform vec2 u_cell_size;varying float v_color_t;void main(){vec2 A=0.5*u_cell_size;vec2 B=u_cell_size-2.*u_cell_inset;float C=a_cell.x-A.x+u_cell_inset.x+a_corner.x*B.x;float D=a_cell.y-A.y+u_cell_inset.y+a_corner.y*B.y;gl_Position=u_projection*vec4(C,D,0.,1.);v_color_t=a_color_t;}\";var gi=\"precision highp float;uniform sampler2D u_gradient_lut;varying float v_color_t;void main(){float A=clamp(v_color_t,0.,1.);vec4 B=texture2D(u_gradient_lut,vec2(A,0.5));gl_FragColor=vec4(B.rgb,1.);}\";var hi=\"attribute float a_strip_t;attribute float a_side;attribute vec2 a_angles;attribute vec2 a_radii;attribute vec4 a_color;uniform vec2 u_center;uniform vec2 u_resolution;uniform float u_border_px;varying vec4 v_color;varying vec2 v_edge;void main(){float A=u_border_px*0.5;float B=a_radii.x+A;float C=a_radii.y-A;if(C<=B){gl_Position=vec4(2.,2.,2.,1.);v_color=vec4(0.);v_edge=vec2(0.);return;}float D=mix(B,C,a_side);float E=A/max(D,1.);float F=a_angles.y-a_angles.x;E=min(E,F*0.5);float G=mix(a_angles.x+E,a_angles.y-E,a_strip_t);vec2 H=u_center+vec2(cos(G),sin(G))*D;vec2 I=(H/u_resolution)*2.-1.;gl_Position=vec4(I.x,-I.y,0.,1.);v_color=a_color;v_edge=vec2(a_strip_t,a_side);}\";var xi=\"precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}\";var yi=\"attribute vec2 a_position;attribute vec4 a_color;uniform vec2 u_resolution;varying vec4 v_color;void main(){vec2 A=(a_position/u_resolution)*2.-1.;A.y=-A.y;gl_Position=vec4(A,0.,1.);v_color=a_color;}\";var _i=\"precision highp float;varying vec4 v_color;void main(){gl_FragColor=v_color;}\";xr();yr();_r();Cr();vr();Ar();Lr();var Tr=[{name:\"bar\",vert:ii,frag:oi},{name:\"line\",vert:ri,frag:si},{name:\"scatter\",vert:li,frag:ai},{name:\"bar-area\",vert:ui,frag:mi},{name:\"bar-scatter\",vert:fi,frag:ci},{name:\"line-uniform\",vert:Ke,frag:Je},{name:\"candlestick-body\",vert:di,frag:pi},{name:\"heatmap\",vert:bi,frag:gi},{name:\"sunburst-arc\",vert:hi,frag:xi},{name:\"treemap\",vert:yi,frag:_i},{name:\"density-splat\",vert:Wt,frag:Ci},{name:\"density-extreme\",vert:Wt,frag:vi},{name:\"density-resolve\",vert:Ai,frag:Li},{name:\"map-tile\",vert:Ti,frag:wi}];var Hm=1,ht=class{constructor(t,n={}){p(this,\"id\");p(this,\"canvas\");p(this,\"gl\");p(this,\"isWebGL2\");p(this,\"shaders\");p(this,\"Io\");p(this,\"Eo\",null);p(this,\"Jt\");p(this,\"xt\",!1);p(this,\"ri\",new Set);this.id=Hm++,this.canvas=t,this.Jt=n.precompile??!1;let i=t.getContext(\"webgl2\",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(i)this.gl=i,this.isWebGL2=!0;else{let o=t.getContext(\"webgl\",{antialias:!0,alpha:!0,premultipliedAlpha:!1});if(!o)throw new Error(\"WebGL is not supported\");this.gl=o,this.isWebGL2=!1}this.shaders=new yn(this.gl),this.Jt&&this.shaders.precompile(Tr),this.Io=this.gl.getParameter(this.gl.MAX_VERTEX_ATTRIBS),this.isWebGL2||(this.Eo=this.gl.getExtension(\"ANGLE_instanced_arrays\")),t.addEventListener(\"webglcontextlost\",o=>{this.xt||o.preventDefault()}),t.addEventListener(\"webglcontextrestored\",()=>{this.shaders.releaseAll(),this.shaders=new yn(this.gl),this.Jt&&this.shaders.precompile(Tr);for(let o of this.ri)o()})}resetVertexArrayState(){let t=this.gl;for(let n=0;n<this.Io;n++)t.disableVertexAttribArray(n),this.isWebGL2?t.vertexAttribDivisor(n,0):this.Eo?.vertexAttribDivisorANGLE(n,0)}onRestore(t){return this.ri.add(t),()=>this.ri.delete(t)}isContextLost(){return this.xt||this.gl.isContextLost()}get destroyed(){return this.xt}destroy(){this.xt=!0,this.ri.clear(),this.shaders.releaseAll();let t=this.gl.getExtension(\"WEBGL_lose_context\");t&&t.loseContext()}};var _n=class{constructor(t,n={}){p(this,\"P\");p(this,\"si\");p(this,\"Po\");p(this,\"r\");p(this,\"li\",0);p(this,\"zi\",0);p(this,\"Yi\",0);p(this,\"Xi\",1);p(this,\"xt\",!1);p(this,\"ai\",null);p(this,\"yt\",null);p(this,\"wn\",null);p(this,\"Qt\",null);t instanceof ht?(this.P=t,this.si=!1):(this.P=new ht(t,{precompile:n.precompile??!1}),this.si=!0),this.r=new xn(this.P.gl),this.Po=this.P.onRestore(()=>{this.r.releaseAll(),this.r=new xn(this.P.gl),this.li=0})}get gl(){return this.P.gl}get backendId(){return this.P.id}isContextLost(){return this.xt||this.P.isContextLost()}get isWebGL2(){return this.P.isWebGL2}get shaders(){return this.P.shaders}get A(){return this.r}get uploadedCount(){return this.li}set uploadedCount(t){this.li=t}resize(t,n,i){this.zi=t,this.Yi=n,this.Xi=i;let o=Math.round(t*i),r=Math.round(n*i),s=this.P.canvas;(s.width!==o||s.height!==r)&&(s.width=o,s.height=r,this.P.gl.viewport(0,0,o,r))}requestResize(t,n,i){this.Qt={cssWidth:t,cssHeight:n,dpr:i}}applyPendingResize(){if(!this.Qt)return!1;let{cssWidth:t,cssHeight:n,dpr:i}=this.Qt;return this.Qt=null,this.resize(t,n,i),!0}beginFrame(){if(this.si){this.applyPendingResize();return}let t=this.Qt;this.Qt=null,t?this.resize(t.cssWidth,t.cssHeight,t.dpr):this.resize(this.zi,this.Yi,this.Xi);let n=this.P.gl,i=this.P.canvas;n.bindFramebuffer(n.FRAMEBUFFER,null),n.viewport(0,0,i.width,i.height),n.disable(n.SCISSOR_TEST),n.disable(n.DEPTH_TEST),this.P.resetVertexArrayState()}get cssWidth(){return this.zi}get cssHeight(){return this.Yi}get dpr(){return this.Xi}clear(){this.P.gl.clearColor(0,0,0,0),this.P.gl.clear(this.P.gl.COLOR_BUFFER_BIT|this.P.gl.DEPTH_BUFFER_BIT),this.li=0}setFrameCallback(t){this.ai=t}endFrame(){if(!this.ai||this.isContextLost())return;let t=this.P.canvas;if(typeof t.transferToImageBitmap!=\"function\")return;let n=t.transferToImageBitmap();this.ai(n)}async awaitGpuFence(){if(!this.P.isWebGL2){this.P.gl.finish();return}let t=this.P.gl,n=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(!n){t.finish();return}try{let i=t.SYNC_FLUSH_COMMANDS_BIT;for(;;){let o=t.clientWaitSync(n,i,0);if(o===t.ALREADY_SIGNALED||o===t.CONDITION_SATISFIED)return;if(o===t.WAIT_FAILED){t.finish();return}if(i=0,await this.Lr(),this.xt)return}}finally{t.deleteSync(n)}}ensureBufferCapacity(t){this.r.ensureCapacity(t)}Lr(){return this.yt||(this.yt=new MessageChannel,this.yt.port1.start()),new Promise(t=>{let n=this.yt;this.wn=t,n.port1.addEventListener(\"message\",()=>{this.wn=null,t()},{once:!0}),n.port2.postMessage(null)})}destroy(){if(this.xt=!0,this.ai=null,this.Po(),this.r.releaseAll(),this.wn){let t=this.wn;this.wn=null,t()}this.yt&&(this.yt.port1.close(),this.yt.port2.close(),this.yt=null),this.si&&this.P.destroy()}};var Mi=class{constructor(t,n={}){p(this,\"Bo\");p(this,\"Jt\");p(this,\"en\",[]);p(this,\"Go\",0);this.Bo=Math.max(1,t),this.Jt=n.precompile??!1}acquire(){let t;if(this.en.length<this.Bo)t=this.Wo(),this.en.push(t);else{let n=this.Go%this.en.length;this.Go++,this.en[n].isContextLost()&&(this.en[n]=this.Wo()),t=this.en[n]}return t}Wo(){let t=new OffscreenCanvas(1,1);return new ht(t,{precompile:this.Jt})}};Ri();Ri();function el(e,t,n,i){let{controller:o,layout:r}=e,s=r.e,l=o.getVisibleDomain(),a=l.xMin+(t-s.x)/s.width*(l.xMax-l.xMin),u=l.yMax-(n-s.y)/s.height*(l.yMax-l.yMin),m=Math.pow(1.1,-i/100),f=o.lockedAxis;f!==\"x\"&&(o.scaleX=Math.max(1,Math.min(1e5,o.scaleX*m))),f!==\"y\"&&(o.scaleY=Math.max(1,Math.min(1e5,o.scaleY*m)));let c=o.getVisibleDomain(),d=c.xMin+(t-s.x)/s.width*(c.xMax-c.xMin),b=c.yMax-(n-s.y)/s.height*(c.yMax-c.yMin),g=o.baseXRange,h=o.baseYRange;f!==\"x\"&&g>0&&(o.normTranslateX+=(a-d)/g),f!==\"y\"&&h>0&&(o.normTranslateY+=(u-b)/h)}function tl(e,t,n){let{controller:i,layout:o}=e,r=i.getVisibleDomain(),s=o.e,l=(r.xMax-r.xMin)/s.width,a=(r.yMax-r.yMin)/s.height,u=i.lockedAxis,m=i.baseXRange,f=i.baseYRange;u!==\"x\"&&m>0&&(i.normTranslateX-=t*l/m),u!==\"y\"&&f>0&&(i.normTranslateY+=n*a/f)}be();var Di=class{constructor(t){p(this,\"sn\");this.sn=t}pin(t,n,i,o=Qe){this.sn({kind:\"pinTooltip\",grid:t,style:o,pos:n,bounds:i})}dismiss(){this.sn({kind:\"dismissTooltip\"})}setCursor(t){this.sn({kind:\"setCursor\",cursor:t})}emitUserClick(t){this.sn({kind:\"userClick\",detail:t})}emitUserSelect(t){this.sn({kind:\"userSelect\",selected:t.selected,row:t.row,column_names:t.column_names,insertConfig:t.insertConfig})}};rs();Ln();var go=class{constructor(t=1024){p(this,\"size\");p(this,\"value\");p(this,\"colorValue\");p(this,\"sizeSign\");p(this,\"x0\");p(this,\"y0\");p(this,\"x1\");p(this,\"y1\");p(this,\"a0\");p(this,\"a1\");p(this,\"r0\");p(this,\"r1\");p(this,\"depth\");p(this,\"parent\");p(this,\"firstChild\");p(this,\"nextSibling\");p(this,\"lastChild\");p(this,\"childCount\");p(this,\"leafRowIdx\");p(this,\"name\");p(this,\"colorLabel\");p(this,\"count\",0);p(this,\"capacity\",0);this.sr(t)}reset(){this.count>0&&(this.x0.fill(0,0,this.count),this.y0.fill(0,0,this.count),this.x1.fill(0,0,this.count),this.y1.fill(0,0,this.count),this.a0.fill(0,0,this.count),this.a1.fill(0,0,this.count),this.r0.fill(0,0,this.count),this.r1.fill(0,0,this.count)),this.count=0}allocate(){this.count===this.capacity&&this.sr(this.capacity*2);let t=this.count++;return this.firstChild[t]=-1,this.nextSibling[t]=-1,this.lastChild[t]=-1,this.childCount[t]=0,this.leafRowIdx[t]=-1,this.size[t]=0,this.value[t]=0,this.colorValue[t]=NaN,this.sizeSign[t]=1,this.name[t]=\"\",this.colorLabel[t]=\"\",t}appendChild(t,n){this.parent[n]=t,this.depth[n]=this.depth[t]+1,this.nextSibling[n]=-1;let i=this.lastChild[t];i===-1?this.firstChild[t]=n:this.nextSibling[i]=n,this.lastChild[t]=n,this.childCount[t]++}isLeaf(t){return this.firstChild[t]===-1}sr(t){let n=Math.max(t,1024),i=(o,r)=>{let s=new r(n);return o&&o.length>0&&s.set(o),s};this.size=i(this.size,Float32Array),this.value=i(this.value,Float32Array),this.colorValue=i(this.colorValue,Float32Array),this.sizeSign=i(this.sizeSign,Int8Array),this.x0=i(this.x0,Float32Array),this.y0=i(this.y0,Float32Array),this.x1=i(this.x1,Float32Array),this.y1=i(this.y1,Float32Array),this.a0=i(this.a0,Float32Array),this.a1=i(this.a1,Float32Array),this.r0=i(this.r0,Float32Array),this.r1=i(this.r1,Float32Array),this.depth=i(this.depth,Int32Array),this.parent=i(this.parent,Int32Array),this.firstChild=i(this.firstChild,Int32Array),this.nextSibling=i(this.nextSibling,Int32Array),this.lastChild=i(this.lastChild,Int32Array),this.childCount=i(this.childCount,Int32Array),this.leafRowIdx=i(this.leafRowIdx,Int32Array),this.name?this.name.length=n:this.name=new Array(n),this.colorLabel?this.colorLabel.length=n:this.colorLabel=new Array(n),this.capacity=n}};function Sa(e,t){let n=[],i=t;for(;e.parent[i]!==-1;)n.push(e.name[i]),i=e.parent[i];return n.reverse()}Qr();function ho(e){for(let t of e.keys())if(!t.startsWith(\"__\"))return t;return\"\"}var rn=class extends De{constructor(){super(...arguments);p(this,\"re\",\"\");p(this,\"s\",\"\");p(this,\"ue\",\"empty\");p(this,\"m\",new go);p(this,\"K\",-1);p(this,\"C\",-1);p(this,\"pe\",[]);p(this,\"Vt\",new Map);p(this,\"Si\",0);p(this,\"p\",1/0);p(this,\"c\",-1/0);p(this,\"a\",new Map);p(this,\"J\",null);p(this,\"me\",0);p(this,\"U\",new en)}colorScaleColumn(){return this.L[1]||null}};Tn();kn();Ce();function Dt(e,t,n,i,o){if(!e||t<=0)return null;let r=new Float64Array(t),s=1/0,l=-1/0;for(let u=0;u<t;u++){let m=e[u+n];r[u]=m,m<s&&(s=m),m>l&&(l=m)}let a=1/0;for(let u=1;u<t;u++){let m=Math.abs(r[u]-r[u-1]);m>0&&m<a&&(a=m)}return(!isFinite(a)||a===0)&&(a=Math.max(1,l-s)),{categoryPositions:r,numericCategoryDomain:{min:s-a/2,max:l+a/2,isDate:o,label:i,bandWidth:a}}}function sn(e,t){if(e.length!==1)return{mode:\"category\"};let n=t[e[0]];return n===\"date\"||n===\"datetime\"||n===\"integer\"||n===\"float\"?{mode:\"numeric\",numericType:n}:{mode:\"category\"}}function sc(e,t,n){return!t||e==null||Number.isNaN(e)?\"\":n===\"boolean\"?e?\"true\":\"false\":n===\"date\"||n===\"datetime\"?Yt(e):n===\"integer\"?String(e|0):n===\"float\"?Ee(e):String(e)}function ss(e,t,n){let i=e.values,o=e.valid,r=new Int32Array(t),s=[\"\"],l=new Map;l.set(\"\",0);let a=new Map;for(let u=0;u<t;u++){if(!(o?!!(o[u>>3]>>(u&7)&1):!0)){r[u]=0;continue}let f=i[u],c=a.get(f);if(c===void 0){let d=sc(f,!0,n);c=l.get(d),c===void 0&&(c=s.length,s.push(d),l.set(d,c)),a.set(f,c)}r[u]=c}return{indices:r,dictionary:s}}function ln(e,t,n,i=[],o){if(o?.mode===\"numeric\"){let m=e.get(\"__ROW_PATH_0__\");if(m&&m.type!==\"string\"&&m.values){let f=0,c=m.values,d=m.valid;for(;f<t;){let b=d?!!(d[f>>3]>>(f&7)&1):!0,g=c[f];if(b&&g!=null&&!Number.isNaN(g))break;f++}return{rowPaths:[],numCategories:Math.max(0,t-f),rowOffset:f}}}let r=[];for(let m=0;;m++){let f=e.get(`__ROW_PATH_${m}__`);if(!f)break;if(f.type===\"string\"&&f.indices&&f.dictionary)r.push({indices:f.indices,dictionary:f.dictionary});else if(f.values){let c=i[m]??\"string\";r.push(ss(f,t,c))}else break}let s=0;if(n>0&&r.length>0)for(;s<t;){let m=!1;for(let f of r){let c=f.dictionary[f.indices[s]];if(c!=null&&c!==\"\"){m=!0;break}}if(m)break;s++}let l=Math.max(0,t-s),a=r.length;return{rowPaths:n>0&&a>0?r.map((m,f)=>{let c=new Array(l),d=0;for(let g=0;g<l;g++){let h=m.dictionary[m.indices[g+s]]??\"\";c[g]=h,h.length>d&&(d=h.length)}let b=f===a-1?[]:no(m.indices,m.dictionary,s,s+l).map(g=>({startIdx:g.startIdx-s,endIdx:g.endIdx-s,label:g.label}));return{labels:c,runs:b,maxLabelChars:d}}):[],numCategories:l,rowOffset:s}}function ls(e,t,n,i){if(e.length===0)return null;for(let c of e)if(c.type!==\"string\")return null;let o=Math.max(0,t-n),r=[],s=new Map,l=e.map(()=>new Int32Array(o)),a=c=>{let d=s.get(c);return d===void 0&&(d=r.length,r.push(c),s.set(c,d)),d};for(let c=0;c<e.length;c++){let d=e[c].data,b=l[c];for(let g=0;g<o;g++){let h=g+n,x;if(!d)x=\"(null)\";else{let y=d.valid;if(!(y?!!(y[h>>3]>>(h&7)&1):!0))x=\"(null)\";else if(d.indices&&d.dictionary)x=d.dictionary[d.indices[h]]??\"(null)\";else if(d.values){let _=d.values[h];x=_==null?\"(null)\":String(_)}else x=\"(null)\"}b[g]=a(x)}}let u=0;for(let c of r)c.length>u&&(u=c.length);return{domain:{levels:[{labels:r.slice(),runs:[],maxLabelChars:u}],numRows:r.length,levelLabels:[i]},perColumnSlots:l}}function Hn(e){e.m.reset(),e.Vt.clear();let t=e.m.allocate();e.m.name[t]=\"Total\",e.m.depth[t]=0,e.m.parent[t]=-1,e.Vt.set(t,new Map),e.K=t,e.C=t,e.pe=[t],e.Si=0,e.p=1/0,e.c=-1/0,e.a.clear(),e.J=null,e.me=0}function lc(e,t,n){let i=e.Vt.get(t);i||(i=new Map,e.Vt.set(t,i));let o=i.get(n);if(o!==void 0)return o;let r=e.m.allocate();return e.m.name[r]=n,e.m.appendChild(t,r),i.set(n,r),r}function xo(e,t,n,i,o,r,s){let l=e.K,a=t.length;for(let u=0;u<a;u++){let m=lc(e,l,t[u]);u===a-1&&((s===0||a===s)&&(e.m.size[m]=Math.abs(n),e.m.sizeSign[m]=n<0?-1:1,e.m.leafRowIdx[m]=r),isNaN(i)||(e.m.colorValue[m]=i,i<e.p&&(e.p=i),i>e.c&&(e.c=i)),o&&(e.m.colorLabel[m]=o,e.a.has(o)||e.a.set(o,e.a.size))),l=m}}function Ia(e,t){let n=e.valid;return!n||!!(n[t>>3]>>(t&7)&1)}function yo(e,t){return e?.values?Ia(e,t)?e.values[t]:0:1}function _o(e,t,n){let i=NaN,o=\"\";return!t||!Ia(t,n)?{colorValue:i,colorLabel:o}:(e.ue===\"numeric\"&&t.values?i=t.values[n]:e.ue===\"series\"&&t.indices&&t.dictionary&&(o=t.dictionary[t.indices[n]]),{colorValue:i,colorLabel:o})}function Da(e,t){if(e.ue!==\"series\"||!t?.dictionary)return;let n=t.dictionary;for(let i=0;i<n.length;i++){let o=n[i];e.a.has(o)||e.a.set(o,e.a.size)}}function ac(e,t){if(e.B.length===0)return null;let n=e.re?[e.re]:[],i=e.s?[e.s]:[],o=it(t,n,i);return o.length===0?null:o.map(r=>({prefix:r.prefix,sizeCol:e.re?t.get(`${r.prefix}|${e.re}`)??null:null,colorCol:e.s?t.get(`${r.prefix}|${e.s}`)??null:null}))}function Vn(e,t){let n=[];for(let g=0;;g++){let h=t.get(`__ROW_PATH_${g}__`);if(!h)break;if(h.type===\"string\"&&h.indices&&h.dictionary)n.push({indices:h.indices,dictionary:h.dictionary,valid:h.valid});else if(h.values){let x=e.h[g],y=e.vt[x]??\"string\";n.push(ss(h,h.values.length,y))}else break}let i=n.length>0,o=e.h.length,r=ac(e,t),s=r!==null,l=e.re?t.get(e.re):null,a=e.s?t.get(e.s):null,u=s?r[0].sizeCol:l,m=i?n[0].indices.length:u?.values?.length??0;if(m===0)return;if(s)for(let g of r)Da(e,g.colorCol);else Da(e,a);let f=e.Si,c=s&&i?o+1:o;if(!i){let g;for(let[x,y]of t){if(x.startsWith(\"__\")||s&&x.includes(\"|\"))continue;let C=x.lastIndexOf(\"|\"),_=C===-1?x:x.substring(C+1);if(!(_===e.re||_===e.s)&&y.type===\"string\"&&y.indices&&y.dictionary){g=y;break}}let h=s?r:null;for(let x=0;x<m;x++){let y=g?.indices&&g?.dictionary?g.dictionary[g.indices[x]]:`Row ${f+x}`;if(h)for(let C of h){let _=yo(C.sizeCol,x),{colorValue:v,colorLabel:A}=_o(e,C.colorCol,x);xo(e,[C.prefix,y],_,v,A,f+x,c)}else{let C=yo(l,x),{colorValue:_,colorLabel:v}=_o(e,a,x);xo(e,[y],C,_,v,f+x,c)}}e.Si=f+m;return}let d=s?1:0,b=new Array(n.length+d);for(let g=0;g<m;g++){let h=0;for(let x=0;x<n.length;x++){let y=n[x];if(y.valid&&!(y.valid[g>>3]>>(g&7)&1))break;let C=y.dictionary[y.indices[g]];if(!C&&C!==\"0\")break;b[d+h++]=C}if(h!==0)if(s)for(let x of r){b[0]=x.prefix;let y=b.slice(0,h+1),C=yo(x.sizeCol,g),{colorValue:_,colorLabel:v}=_o(e,x.colorCol,g);xo(e,y,C,_,v,f+g,c)}else{let x=b.slice(0,h),y=yo(l,g),{colorValue:C,colorLabel:_}=_o(e,a,g);xo(e,x,y,C,_,f+g,c)}}e.Si=f+m}function zn(e){let t=e.m,n=t.value,i=t.size,o=t.firstChild,r=t.nextSibling,s=new Int32Array(128);s[0]=e.K,s[1]=0;let l=1;for(let a=0;a<t.count;a++)n[a]=0;for(;l>0;){l--;let a=s[l*2];if(s[l*2+1]===0){s[l*2+1]=1,l++;for(let m=o[a];m!==-1;m=r[m]){if((l+1)*2>s.length){let f=new Int32Array(s.length*2);f.set(s),s=f}s[l*2]=m,s[l*2+1]=0,l++}}else if(o[a]===-1){let m=i[a];n[a]=m>0?m:0}else{let m=0;for(let f=o[a];f!==-1;f=r[f])m+=n[f];n[a]=m}}if(e.pe.length>1){let a=[];for(let f=1;f<e.pe.length;f++)a.push(t.name[e.pe[f]]);let u=e.K,m=!0;for(let f of a){let d=e.Vt.get(u)?.get(f);if(d===void 0){m=!1;break}u=d}if(m&&t.firstChild[u]!==-1){e.C=u,Co(e,u);return}}e.C=e.K,e.pe=[e.K]}function Co(e,t){let n=[],i=t;for(;i!==-1;)n.unshift(i),i=e.m.parent[i];e.pe=n}var uc=1,as=14,Ea=1,Pa=4;function vo(e,t,n,i,o,r,s,l,a){if(e.x0[t]=Math.round(n),e.y0[t]=Math.round(i),e.x1[t]=Math.round(o),e.y1[t]=Math.round(r),e.firstChild[t]===-1||(o-n)*(r-i)<Pa)return;let m=e.depth[t]-s,f=a&&m===1&&e.firstChild[t]!==-1,c=f?as:Ea,d=f?uc:Ea,b=e.x0[t]+d,g=e.y0[t]+c,h=e.x1[t]-d,x=e.y1[t]-d;if(h<=b||x<=g)return;let y=0;for(let C=e.firstChild[t];C!==-1;C=e.nextSibling[C])e.value[C]>0&&(l[y++]=C);y!==0&&Yn(e,l,0,y,b,g,h,x,s,l.subarray(y),a)}function Yn(e,t,n,i,o,r,s,l,a,u,m){let f=i-n;if(f===0)return;if(f===1){vo(e,t[n],o,r,s,l,a,u,m);return}let c=0;for(let v=n;v<i;v++)c+=e.value[t[v]];let d=c/2,b=0,g=n+1,h=1/0;for(let v=n;v<i-1;v++){b+=e.value[t[v]];let A=Math.abs(b-d);A<h&&(h=A,g=v+1)}let x=0;for(let v=n;v<g;v++)x+=e.value[t[v]];let y=x/c,C=s-o,_=l-r;if(C>=_){let v=Math.round(o+C*y);Yn(e,t,n,g,o,r,v,l,a,u,m),Yn(e,t,g,i,v,r,s,l,a,u,m)}else{let v=Math.round(r+_*y);Yn(e,t,n,g,o,r,s,v,a,u,m),Yn(e,t,g,i,o,v,s,l,a,u,m)}}function Ba(e,t,n,i){e.me=us(e,t,n,i,0)}function us(e,t,n,i,o){let r=e.m,s=r.x0,l=r.y0,a=r.x1,u=r.y1,m=r.depth,f=r.firstChild,c=r.nextSibling,d=r.value;(!e.J||e.J.length<r.count)&&(e.J=new Int32Array(r.count));let b=e.J,g=o,h=new Int32Array(128);h[0]=t;let x=1;for(;x>0;){x--;let y=h[x];if(d[y]<=0||(m[y]>=i&&(b[g++]=y),m[y]-i>=n))continue;let C=a[y]-s[y],_=u[y]-l[y];if(!(C*_<Pa))for(let v=f[y];v!==-1;v=c[v]){if(x>=h.length){let A=new Int32Array(h.length*2);A.set(h),h=A}h[x++]=v}}return g}Rn();Ht();Ve();ge();function Ao(e,t,n){return .299*e+.587*t+.114*n}function mc(e,t){let n=Se(e,t);return[n[0],n[1],n[2]]}function Xn(e,t,n,i){let o=e.m,r=o.colorValue[t];if(e.ue===\"numeric\"&&!isNaN(r)&&e.c>e.p)return mc(n,Ct(r,e.p,e.c));let s=e.a.get(o.colorLabel[t])??0;return i[s%i.length]??[0,0,0]}function Lo(e,t,n,i,o){let r=Xn(e,t,n,i),s=e.m.sizeSign[t]<0?o:1;return[r[0],r[1],r[2],s]}de();function To(e,t,n,i,o,r,s){let l=Math.round(i*n),a=Math.round(o*n);(t.width!==l||t.height!==a)&&(t.width=l,t.height=a,e.Tt=!0);let u=t.getContext(\"2d\");if(u){if(e.Tt){e.be?.close(),e.be=null,e.Tt=!1;let m=++e.On;r(u),createImageBitmap(t).then(f=>{e.On===m?(e.be?.close(),e.be=f):f.close()})}else e.be&&(u.clearRect(0,0,t.width,t.height),u.drawImage(e.be,0,0));s&&(u.save(),u.scale(n,n),s(u),u.restore())}}to();ot();Nn();Ve();be();function Ga(e,t,n,i,o,r,s,l,a=Qe){if(n.length===0)return;e.font=`11px ${l}`;let u=Fi(e,n,a.maxColumnPx),{boxW:m,boxH:f}=u,c=i+12,d=o-f-8;c+m>r&&(c=i-m-12),c<0&&(c=4),d<0&&(d=o+12),d+f>s&&(d=s-f-4),Si(e,u,c,d,t,a.opacity)}be();var Wa=24,fc=8,ka=12,Na=2,Oa=\" \\u203A \";function wo(e,t,n,i,o){e.qe=[];let r=e.v().mi;t.fillStyle=r,t.fillRect(0,0,n,Wa),t.font=`11px ${i}`,t.textAlign=\"left\",t.textBaseline=\"middle\";let s=fc,l=e.m;for(let a=0;a<e.pe.length;a++){let u=e.pe[a],m=a===e.pe.length-1,f=l.name[u];t.fillStyle=o;let c=t.measureText(f).width;t.fillText(f,s,ka),e.qe.push({nodeId:u,x0:s-Na,y0:0,x1:s+c+Na,y1:Wa}),s+=c,m||(t.fillText(Oa,s,ka),s+=t.measureText(Oa).width)}}function Mo(e,t,n,i,o,r,s,l){let a=e.U.hoveredTarget===n?e.U.grid??[]:[];a.length!==0&&Ga(t,e.v(),a,i,o,r,s,l,ie(e.t))}function Ro(e,t,n,i,o,r,s,l=null){let a=e.t,u=e.ue===\"series\"&&e.a.size>1,m=e.ue===\"numeric\"&&e.p<e.c,f=se(a,u?e.a.size:0);if(f===\"none\"||!u&&!m){e.F.clearPainted();return}let c=f===\"floating\",d={mode:c?\"floating\":\"sidebar\",legend:e.F,title:e.s||\"Legend\",opacity:a.legend_opacity},b=c?e.F.floatingBox(a,r,s,u?st(t,o,e.a.size,()=>e.a.keys(),{title:d.title}):Rt(t,o,{min:e.p,max:e.c},void 0,d.title)):null;if(u)b?Ft(t,b,e.a,n,o,d):l?Ft(t,l,e.a,n,o,{...d,sidebarGutter:l.width}):so(t,Ua(r,s,a),e.a,n,o,d);else{let g={min:e.p,max:e.c,label:e.s},h=e.getColumnFormatter(e.s,\"value\");b?$e(t,b,g,i,o,h,d):Qt(t,Ua(r,s,a),g,i,o,h,d)}}function Ua(e,t,n){return new oe(e,t,{hasXLabel:!1,hasYLabel:!1,hasLegend:!0,rightExtra:we(n,80)})}function Ha(e,t){if(e.C===-1)return;let n=t.gl,i=t.cssWidth,o=t.cssHeight;if(i<=0||o<=0)return;let r=e.m,s=e.B.length>0&&e.W.facet_mode===\"grid\",l=e.pe.length>1?28:0,a=e.ue===\"series\"?e.a.size>1:e.ue===\"numeric\"&&e.p<e.c,u=Ni(e.t,a,90,e.ue===\"series\"?e.a.size:0),m=new Int32Array(Math.max(r.count,64));if(s)cc(e,m,i,o,l,u);else{e.b=null;let b=r.depth[e.C];vo(r,e.C,0,l,i-u,o,b,m,e.Di),Ba(e,e.C,100,b),fs(e);let g=e.ze,h=e.Ke;for(let x=0;x<e.me;x++)g[x]=b,h[x]=e.C}if(!e.o){let b=j(t,\"treemap\",yi,_i,[\"u_resolution\"],[\"a_position\",\"a_color\"]);e.o=b.program,e.E=b}let f=e.v(),c=f.N,d=he(f.Ne,c,Math.max(1,e.a.size));if(e.Q){let b=e.Q.getContext(\"2d\");b&&b.clearRect(0,0,e.Q.width,e.Q.height)}e.Tt=!0,dc(e,n,c,d,f.pi),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.o),n.uniform2f(e.E.u_resolution,i,o),n.bindBuffer(n.ARRAY_BUFFER,e.zt),n.enableVertexAttribArray(e.E.a_position),n.vertexAttribPointer(e.E.a_position,2,n.FLOAT,!1,0,0),n.bindBuffer(n.ARRAY_BUFFER,e.Yt),n.enableVertexAttribArray(e.E.a_color),n.vertexAttribPointer(e.E.a_color,4,n.FLOAT,!1,0,0),n.drawArrays(n.TRIANGLES,0,e.co),e._e(()=>an(e))}function cc(e,t,n,i,o,r){let s=e.m,l=[],a=[];for(let b=s.firstChild[e.K];b!==-1;b=s.nextSibling[b])s.value[b]<=0||(l.push(b),a.push(s.name[b]));let u=Math.max(1,i-o),m=Math.max(1,n-r),f=Ie(a,{cssWidth:m,cssHeight:u,hasLegend:!1,xAxis:\"none\",yAxis:\"none\",gap:e.W.facet_padding});e.b=f,fs(e);let c=e.ze,d=0;for(let b=0;b<l.length;b++){let g=l[b],h=f.cells[b];if(!h)continue;let x=s.name[g],y=e.ct.get(x)??g,C=s.depth[y],_=h.layout.e;vo(s,y,_.x,_.y+o,_.x+_.width,_.y+o+_.height,C,t,e.Di);let v=us(e,y,100,C,d);c.length<v&&fs(e);let A=e.ze,L=e.Ke;for(let T=d;T<v;T++)A[T]=C,L[T]=y;d=v}e.me=d}function fs(e){let t=e.J?.length??e.m.count;(!e.ze||e.ze.length<t)&&(e.ze=new Int32Array(t)),(!e.Ke||e.Ke.length<t)&&(e.Ke=new Int32Array(t))}function dc(e,t,n,i,o){let r=e.m,s=e.J,l=e.me,a=e.ze,u=e.Ke,m=h=>a?a[h]:r.depth[e.C],f=h=>u?u[h]:e.C,c=0;for(let h=0;h<l;h++){let x=s[h];if(x===f(h))continue;let y=r.x1[x]-r.x0[x],C=r.y1[x]-r.y0[x];y<1||C<1||(r.firstChild[x]===-1?c++:r.depth[x]-m(h)===1&&(c+=2))}let d=new Float32Array(c*6*2),b=new Float32Array(c*6*4),g=0;for(let h=0;h<l;h++){let x=s[h];if(x===f(h))continue;let y=r.x0[x],C=r.y0[x],_=r.x1[x],v=r.y1[x],A=_-y,L=v-C;if(!(A<1||L<1)){if(r.firstChild[x]===-1){let T=Lo(e,x,n,i,o);g=ms(d,b,g,y,C,_-1,v-1,T)}else if(r.depth[x]-m(h)===1){let w=[.25,.25,.25,1];g=ms(d,b,g,y,v-1,_,v,w),g=ms(d,b,g,_-1,C,_,v,w)}}}e.co=g,e.zt||(e.zt=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.zt),t.bufferData(t.ARRAY_BUFFER,d.subarray(0,g*2),t.DYNAMIC_DRAW),e.Yt||(e.Yt=t.createBuffer()),t.bindBuffer(t.ARRAY_BUFFER,e.Yt),t.bufferData(t.ARRAY_BUFFER,b.subarray(0,g*4),t.DYNAMIC_DRAW)}function ms(e,t,n,i,o,r,s,l){let a=n*2,u=n*4;e[a+0]=i,e[a+1]=o,e[a+2]=r,e[a+3]=o,e[a+4]=i,e[a+5]=s,e[a+6]=r,e[a+7]=o,e[a+8]=r,e[a+9]=s,e[a+10]=i,e[a+11]=s;for(let m=0;m<6;m++)t[u+m*4+0]=l[0],t[u+m*4+1]=l[1],t[u+m*4+2]=l[2],t[u+m*4+3]=l[3];return n+6}function an(e){pc(e),e.presentOverlay()}function pc(e){if(!e.l||e.C===-1)return;let t=e.i;if(!t)return;let{dpr:n,cssWidth:i,cssHeight:o}=t,r=e.fe!==-1?e.fe:e.G;To(e,e.l,n,i,o,s=>bc(e,s,n,i,o),r!==-1?s=>{let l=e.v(),{fontFamily:a}=l,u=e.m;gc(s,u,r);let m=e.J,f=e.me,c=e.ze,d=e.Ke;for(let b=0;b<f;b++){let g=m[b],h=d?d[b]:e.C;if(g===h||u.firstChild[g]===-1)continue;let x=u.x1[g]-u.x0[g],y=u.y1[g]-u.y0[g],C=c?c[b]:u.depth[e.C],_=u.depth[g]-C;_===1?Fo(s,u,g,x,y,l,!e.Di):_===2&&Fo(s,u,g,x,y,l,!0)}if(u.firstChild[r]===-1){let b=l.N,g=he(l.Ne,b,Math.max(1,e.a.size)),h=u.x1[r]-u.x0[r],x=u.y1[r]-u.y0[r];Va(e,s,r,h,x,a,b,g,!0)}e.fe===-1&&e.G!==-1&&hc(e,s,e.G,i,o,a)}:null)}function bc(e,t,n,i,o){let r=e.l;t.clearRect(0,0,r.width,r.height),t.save(),t.scale(n,n);let s=e.v(),{fontFamily:l,Fe:a}=s,u=s.N,m=he(s.Ne,u,Math.max(1,e.a.size)),f=e.m,c=e.J,d=e.me,b=e.ze,g=e.Ke;for(let h=0;h<d;h++){let x=c[h],y=g?g[h]:e.C;if(x===y||f.firstChild[x]!==-1)continue;let C=f.x1[x]-f.x0[x],_=f.y1[x]-f.y0[x];Va(e,t,x,C,_,l,u,m)}for(let h=0;h<d;h++){let x=c[h],y=g?g[h]:e.C;if(x===y||f.firstChild[x]===-1)continue;let C=f.x1[x]-f.x0[x],_=f.y1[x]-f.y0[x],v=b?b[h]:f.depth[e.C],A=f.depth[x]-v;A===1?Fo(t,f,x,C,_,s,!e.Di):A===2&&Fo(t,f,x,C,_,s,!0)}if(e.pe.length>1&&wo(e,t,i,l,a),Ro(e,r,m,u,s,i,o),e.b){t.font=`11px ${l}`,t.fillStyle=a,t.textAlign=\"center\",t.textBaseline=\"top\";for(let h of e.b.cells){let x=h.layout.e;t.fillText(h.label,x.x+x.width/2,x.y-14)}}t.restore()}function Va(e,t,n,i,o,r,s,l,a=!1){if(i<30||o<14)return;let c=e.m,d=Xn(e,n,s,l),b=Ao(d[0],d[1],d[2]),g=a?b>.5?\"rgba(0,0,0,0.85)\":\"rgba(255,255,255,0.9)\":b>.5?\"rgba(0,0,0,0.5)\":\"rgba(255,255,255,0.55)\",h=Math.min(11,Math.floor(o/2));if(h<7)return;t.font=`${h}px ${r}`;let x=i-8,y=h*1.3,C=Math.max(1,Math.floor((o-8)/y)),_=ra(t,c.name[n],x,C);if(_.length===0)return;let v=_.length*y,A=c.y0[n]+(o-v)/2+y/2;t.fillStyle=g,t.textAlign=\"center\",t.textBaseline=\"middle\";let L=c.x0[n]+i/2;for(let T=0;T<_.length;T++)t.fillText(_[T],L,A+T*y)}function Fo(e,t,n,i,o,{fontFamily:r,Fe:s,backgroundColor:l},a){let u=t.x0[n],m=t.y0[n],f=t.name[n];if(a){if(i<60||o<30)return;let c=12;e.font=`${c}px ${r}`;let d=f,b=i-16;if(e.measureText(d).width>b){for(;d.length>1;)if(d=d.slice(0,-1),e.measureText(d+\"\\u2026\").width<=b){d+=\"\\u2026\";break}}if(d.length<=3)return;e.save(),e.beginPath(),e.rect(u,m,i,o),e.clip();let h=u+i/2,x=m+o/2;e.textAlign=\"center\",e.textBaseline=\"middle\",e.lineWidth=2,e.strokeStyle=s,e.lineJoin=\"round\",e.strokeText(d,h,x),e.fillStyle=l,e.fillText(d,h,x),e.restore()}else{if(i<40||o<22)return;let c=11;e.font=`${c}px ${r}`;let d=f,b=i-10;if(e.measureText(d).width>b){for(;d.length>1;)if(d=d.slice(0,-1),e.measureText(d+\"\\u2026\").width<=b){d+=\"\\u2026\";break}}e.fillStyle=s,e.globalAlpha=.85,e.textAlign=\"left\",e.textBaseline=\"top\",e.fillText(d,u+5,m+4),e.globalAlpha=1}}function gc(e,t,n){e.strokeStyle=\"rgba(255,255,255,0.9)\",e.lineWidth=2,e.strokeRect(t.x0[n],t.y0[n],t.x1[n]-t.x0[n],t.y1[n]-t.y0[n])}function hc(e,t,n,i,o,r){let s=e.m,l=(s.x0[n]+s.x1[n])/2,a=(s.y0[n]+s.y1[n])/2;Mo(e,t,n,l,a,i,o,r)}be();async function Ze(e,t,n){let i=e.m,o=Sa(i,t),r=e.B.length>0&&e.W.facet_mode===\"grid\",s=r?o.slice(0,e.B.length):[],l=r?o.slice(e.B.length,e.B.length+e.h.length):o.slice(0,e.h.length),a=n===\"leaf\"?i.leafRowIdx[t]??null:null;await e.emitClickAndSelect({rowIdx:a!=null&&a>=0?a:null,columnName:e.re,groupByValues:l,splitByValues:s})}async function It(e,t){let n=e.m,i=[],o=[],r=t;for(;n.parent[r]!==-1;)o.push(n.name[r]),r=n.parent[r];o.reverse(),o.length>0?i.push([o.join(\" \\u203A \")]):i.push([n.name[t]]);let s=e.getColumnFormatter(e.re,\"value\");if(i.push([\"Value\",s(n.value[t])]),e.s&&!isNaN(n.colorValue[t])){let u=e.getColumnFormatter(e.s,\"value\");i.push([e.s,u(n.colorValue[t])])}let l=n.leafRowIdx[t];if(n.firstChild[t]===-1&&l!==-1&&e.Oe){let u=await e.Oe.fetchRow(l);for(let[m,f]of u)f!=null&&(m===e.s&&!isNaN(n.colorValue[t])||(typeof f==\"number\"?i.push([m,e.getColumnFormatter(m,\"value\")(f)]):i.push([m,String(f)])))}return n.firstChild[t]!==-1&&i.push([\"Children\",String(n.childCount[t])]),i}function So(e,t,n,i){e.w.dismiss(),e.fe=t;let o=e.i?.cssWidth??0,r=e.i?.cssHeight??0;It(e,t).then(s=>{e.fe===t&&s.length!==0&&e.w.pin(s,{px:n.cx,py:n.cy},{cssWidth:o,cssHeight:r},ie(e.t))}),e.G=-1,i()}function Do(e){e.w.dismiss(),e.fe=-1}function Io(e,t,n){let i=e.m;if(e.B.length>0&&e.W.facet_mode===\"grid\"){let o=t;for(;o!==-1&&i.parent[o]!==e.K;)o=i.parent[o];o!==-1&&e.ct.set(i.name[o],t),e.G=-1,n();return}e.C=t,Co(e,t),e.G=-1,n()}function cs(e,t,n){let i=e.m,o=i.x0,r=i.y0,s=i.x1,l=i.y1,a=i.depth,u=i.firstChild,m=e.J,f=e.me,c=e.ze,d=e.Ke,b=-1,g=1/0,h=-1,x=1/0,y=-1;if(!m)return{leafId:-1,branchId:-1,inHeader:!1};for(let C=0;C<f;C++){let _=m[C],v=d?d[C]:e.C;if(_===v||!(t>=o[_]&&t<=s[_]&&n>=r[_]&&n<=l[_]))continue;let A=(s[_]-o[_])*(l[_]-r[_]);if(u[_]!==-1){A<x&&(x=A,h=_);let L=c?c[C]:a[e.C],T=a[_]-L;if(T===1&&n<=r[_]+as&&(y=_),T===2){let w=s[_]-o[_],M=l[_]-r[_];if(w>=60&&M>=30){let I=r[_]+M/2,D=o[_]+w/2;Math.abs(n-I)<10&&Math.abs(t-D)<w*.4&&(y=_)}}}else A<g&&(g=A,b=_)}return y!==-1?{leafId:-1,branchId:y,inHeader:!0}:{leafId:b,branchId:h,inHeader:!1}}function za(e,t,n){if(e.fe!==-1)return;for(let l of e.qe)if(t>=l.x0&&t<=l.x1&&n>=l.y0&&n<=l.y1){e.w.setCursor(\"pointer\"),e.G=-1,an(e);return}let{leafId:i,branchId:o,inHeader:r}=cs(e,t,n),s=r?o:i!==-1?i:o;if(s!==e.G){if(e.G=s,e.w.setCursor(o!==-1?\"pointer\":\"default\"),s!==-1){let l=e.U.beginHover(s);It(e,s).then(a=>{e.U.commitHover(l,a)&&an(e)})}else e.U.clearHover();an(e)}}function Ya(e,t,n){if(e.fe!==-1){$n(e),e.emitUnselect();return}for(let s of e.qe)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e.C&&(Eo(e,s.nodeId),e.emitUnselect());return}let{leafId:i,branchId:o,inHeader:r}=cs(e,t,n);o!==-1&&r?(Eo(e,o),Ze(e,o,\"branch\")):i!==-1?($a(e,i),Ze(e,i,\"leaf\")):o!==-1&&(Eo(e,o),Ze(e,o,\"branch\"))}function Xa(e,t,n){let i=e.fe!==-1;$n(e),i&&e.emitUnselect();let{leafId:o,branchId:r}=cs(e,t,n),s=e.m,l=r;if(l===-1&&o!==-1){let a=s.parent[o];a!==e.C&&a!==-1&&(l=a)}l!==-1&&l!==e.C&&s.firstChild[l]!==-1&&(Eo(e,l),Ze(e,l,\"branch\"),o!==-1&&s.firstChild[o]===-1&&($a(e,o),Ze(e,o,\"leaf\")))}function Eo(e,t){Io(e,t,()=>{e.i&&e.requestRender(e.i)})}function $a(e,t){let n=e.m,i=(n.x0[t]+n.x1[t])/2,o=(n.y0[t]+n.y1[t])/2;So(e,t,{cx:i,cy:o},()=>an(e))}function $n(e){Do(e)}var Po=class extends rn{constructor(){super(...arguments);p(this,\"o\",null);p(this,\"E\",null);p(this,\"zt\",null);p(this,\"Yt\",null);p(this,\"co\",0);p(this,\"G\",-1);p(this,\"fe\",-1);p(this,\"qe\",[]);p(this,\"be\",null);p(this,\"Tt\",!0);p(this,\"On\",0);p(this,\"ct\",new Map);p(this,\"b\",null);p(this,\"Di\",!1);p(this,\"ze\",null);p(this,\"Ke\",null)}tooltipCallbacks(){return{onHover:(n,i)=>za(this,n,i),onLeave:()=>{this.G!==-1&&this.fe===-1&&(this.G=-1,this.i&&this.requestRender(this.i))},onClickPre:(n,i)=>(Ya(this,n,i),!0),onDblClick:(n,i)=>Xa(this,n,i)}}async uploadAndRender(n,i,o,r){if(this.i=n,o===0){let s=this.L;if(this.re=s[0]||ho(i)||\"\",this.s=s[1]||\"\",!this.s)this.ue=\"empty\";else{let l=this.je[this.s],a=l===\"float\"||l===\"integer\"||l===\"date\"||l===\"datetime\";this.ue=a?\"numeric\":\"series\"}this.G=-1,this.fe=-1,this.qe=[],this.ct.clear(),this.b=null,this.ze=null,this.Ke=null,this.co=0,this.U.clearHover(),this.U.invalidatePin(),$n(this),this.be?.close(),this.be=null,this.Tt=!0,this.On++,Hn(this)}Vn(this,i),zn(this),this.K!==-1&&await this.requestRender(n)}kt(n){this.K!==-1&&(this.i=n,Ha(this,n))}destroyInternal(){$n(this),this.be?.close(),this.be=null;let n=this.i?.gl;n&&(this.zt&&n.deleteBuffer(this.zt),this.Yt&&n.deleteBuffer(this.Yt)),this.zt=null,this.Yt=null,this.o=null,this.E=null,this.K=-1,this.C=-1,this.pe=[],this.Vt.clear(),this.J=null,this.me=0,this.qe=[],this.ct.clear(),this.b=null,this.ze=null,this.Ke=null}};Rn();Be();de();var ja=4,jn=30;function xc(e,t){let n=0,i=e.depth[t],o=new Int32Array(128);o[0]=t;let r=1;for(;r>0;){r--;let s=o[r],l=e.depth[s]-i;l>n&&(n=l);for(let a=e.firstChild[s];a!==-1;a=e.nextSibling[a]){if(r>=o.length){let u=new Int32Array(o.length*2);u.set(o),o=u}o[r++]=a}}return n}function ds(e,t,n){let i=e.depth[t],o=Math.max(1,xc(e,t)),s=Math.max(0,n-jn)/o;e.a0[t]=0,e.a1[t]=2*Math.PI,e.r0[t]=0,e.r1[t]=jn,Za(e,t,0,2*Math.PI,jn,s,i)}function Za(e,t,n,i,o,r,s){let l=e.value[t];if(l<=0)return;let a=i-n,u=n;for(let m=e.firstChild[t];m!==-1;m=e.nextSibling[m]){let f=e.value[m];if(f<=0)continue;let c=f/l,d=u,b=u+a*c;u=b;let g=o,h=o+r;e.a0[m]=d,e.a1[m]=b,e.r0[m]=g,e.r1[m]=h;let x=b-d,y=(g+h)/2;x*y*r<ja||e.firstChild[m]!==-1&&Za(e,m,d,b,h,r,s)}}function qa(e,t){e.me=ps(e,t,0)}function ps(e,t,n){let i=e.m,o=i.a0,r=i.a1,s=i.r0,l=i.r1,a=i.firstChild,u=i.nextSibling,m=i.value;(!e.J||e.J.length<i.count)&&(e.J=new Int32Array(i.count));let f=e.J,c=n,d=new Int32Array(128);d[0]=t;let b=1;for(;b>0;){b--;let g=d[b];if(m[g]<=0)continue;f[c++]=g;let h=r[g]-o[g],x=(s[g]+l[g])/2,y=h*x,C=l[g]-s[g];if(!(y*C<ja))for(let _=a[g];_!==-1;_=u[_]){if(b>=d.length){let v=new Int32Array(d.length*2);v.set(d),d=v}d[b++]=_}}return c}Ht();Ve();var Bo=32,yc=28,_c=90;function Go(e,t){if(e.d.length===0)return{centerX:e.dt,centerY:e.pt};let n=e.m;for(let i of e.d){let o=t;for(;o!==-1;){if(o===i.drillRoot)return{centerX:i.centerX,centerY:i.centerY};o=n.parent[o]}}return{centerX:e.dt,centerY:e.pt}}function Qa(e,t){if(e.C===-1)return;let n=t.gl,i=t.cssWidth,o=t.cssHeight;if(i<=0||o<=0)return;let r=e.B.length>0&&e.W.facet_mode===\"grid\",s=e.ue===\"series\"?e.a.size>1:e.ue===\"numeric\"&&e.p<e.c,l=!r&&e.pe.length>1?yc:0,a=Ni(e.t,s,_c,e.ue===\"series\"?e.a.size:0);if(r)Cc(e,i,o,a);else{e.b=null,e.d=[];let b=i-a,g=o-l;e.dt=b/2,e.pt=l+g/2,e.po=Math.max(0,Math.min(b,g)/2-4),ds(e.m,e.C,e.po),qa(e,e.C)}vc(e,t);let u=e.v(),m=u.N,f=he(u.Ne,m,Math.max(1,e.a.size));if(e.Q){let b=e.Q.getContext(\"2d\");b&&b.clearRect(0,0,e.Q.width,e.Q.height)}let c=t.dpr;e.Tt=!0,Ac(e,n,m,f,u.pi,c),n.clearColor(0,0,0,0),n.clear(n.COLOR_BUFFER_BIT),n.enable(n.BLEND),n.blendFunc(n.SRC_ALPHA,n.ONE_MINUS_SRC_ALPHA),n.useProgram(e.o);let d=e.E;if(n.uniform2f(d.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(d.u_border_px,u.jo*c),e.d.length>0)for(let b of e.d)b.instanceCount!==0&&(n.uniform2f(d.u_center,b.centerX*c,b.centerY*c),Ka(e,n,t,b.instanceStart,b.instanceCount));else n.uniform2f(d.u_center,e.dt*c,e.pt*c),Ka(e,n,t,0,e.bo);e._e(()=>mt(e))}function Cc(e,t,n,i){let o=e.m,r=[],s=[];for(let f=o.firstChild[e.K];f!==-1;f=o.nextSibling[f])o.value[f]<=0||(r.push(f),s.push(o.name[f]));let l=Math.max(1,t-i),a=Ie(s,{cssWidth:l,cssHeight:n,hasLegend:!1,xAxis:\"none\",yAxis:\"none\",gap:e.W.facet_padding});e.b=a;let u=[],m=0;for(let f=0;f<r.length;f++){let c=r[f],d=a.cells[f];if(!d)continue;let b=o.name[c],g=e.ct.get(b)??c,h=d.layout.e,x=h.x+h.width/2,y=h.y+h.height/2,C=Math.max(0,Math.min(h.width,h.height)/2-4);ds(o,g,C);let _=ps(e,g,m),v=m,A=_-m;u.push({label:b,centerX:x,centerY:y,maxRadius:C,drillRoot:g,instanceStart:v,instanceCount:A,nodeStart:v,nodeCount:A}),m=_}e.me=m,e.d=u,u.length>0&&(e.dt=u[0].centerX,e.pt=u[0].centerY,e.po=u[0].maxRadius)}function vc(e,t){if(e.o)return;let n=t.gl,i=j(t,\"sunburst-arc\",hi,xi,[\"u_center\",\"u_resolution\",\"u_border_px\"],[\"a_strip_t\",\"a_side\",\"a_angles\",\"a_radii\",\"a_color\"]);e.o=i.program,e.E=i;let o=new Float32Array((Bo+1)*2*2);for(let r=0;r<=Bo;r++){let s=r/Bo,l=r*4;o[l+0]=s,o[l+1]=0,o[l+2]=s,o[l+3]=1}e.hn=n.createBuffer(),n.bindBuffer(n.ARRAY_BUFFER,e.hn),n.bufferData(n.ARRAY_BUFFER,o,n.STATIC_DRAW),e.xn=n.createBuffer()}function Ac(e,t,n,i,o,r){let s=e.m,l=e.J,a=e.d.length>0,u=a?e.d.reduce((d,b)=>d+b.instanceCount,0):e.me,m=new Float32Array(u*8),f=0,c=(d,b,g)=>{let h=f;for(let x=d;x<b;x++){let y=l[x];if(y===g)continue;let C=s.a0[y],_=s.a1[y],v=s.r0[y],A=s.r1[y];if(_<=C||A<=v)continue;let L=Lo(e,y,n,i,o),T=f*8;m[T+0]=C,m[T+1]=_,m[T+2]=v*r,m[T+3]=A*r,m[T+4]=L[0],m[T+5]=L[1],m[T+6]=L[2],m[T+7]=L[3],f++}return{rangeStart:h,rangeCount:f-h}};if(a)for(let d of e.d){let b=d.instanceStart,g=b+d.instanceCount,{rangeStart:h,rangeCount:x}=c(b,g,d.drillRoot);d.instanceStart=h,d.instanceCount=x}else c(0,e.me,e.C);e.bo=f,t.bindBuffer(t.ARRAY_BUFFER,e.xn),t.bufferData(t.ARRAY_BUFFER,m.subarray(0,f*8),t.DYNAMIC_DRAW)}function Ka(e,t,n,i,o){if(o===0)return;let r=e.E;t.bindBuffer(t.ARRAY_BUFFER,e.hn);let s=2*Float32Array.BYTES_PER_ELEMENT;t.enableVertexAttribArray(r.a_strip_t),t.vertexAttribPointer(r.a_strip_t,1,t.FLOAT,!1,s,0),t.enableVertexAttribArray(r.a_side),t.vertexAttribPointer(r.a_side,1,t.FLOAT,!1,s,Float32Array.BYTES_PER_ELEMENT);let l=Q(n),{setDivisor:a}=l;a(r.a_strip_t,0),a(r.a_side,0),t.bindBuffer(t.ARRAY_BUFFER,e.xn);let u=8*Float32Array.BYTES_PER_ELEMENT,m=Float32Array.BYTES_PER_ELEMENT,f=i*u;t.enableVertexAttribArray(r.a_angles),t.vertexAttribPointer(r.a_angles,2,t.FLOAT,!1,u,f),a(r.a_angles,1),t.enableVertexAttribArray(r.a_radii),t.vertexAttribPointer(r.a_radii,2,t.FLOAT,!1,u,f+2*m),a(r.a_radii,1),t.enableVertexAttribArray(r.a_color),t.vertexAttribPointer(r.a_color,4,t.FLOAT,!1,u,f+4*m),a(r.a_color,1),l.drawArraysInstanced(t.TRIANGLE_STRIP,0,2*(Bo+1),o),a(r.a_angles,0),a(r.a_radii,0),a(r.a_color,0)}function mt(e){Lc(e),e.presentOverlay()}function Lc(e){if(!e.l||e.C===-1)return;let t=e.i;if(!t)return;let{dpr:n,cssWidth:i,cssHeight:o}=t;To(e,e.l,n,i,o,r=>Tc(e,r,n,i,o),e.G!==-1?r=>{wc(r,e,e.G),Mc(e,r,e.G,i,o,e.v().fontFamily)}:null)}function Tc(e,t,n,i,o){let r=e.l;t.clearRect(0,0,r.width,r.height),t.save(),t.scale(n,n);let s=e.v(),{fontFamily:l,Fe:a,mi:u}=s,m=s.N,f=he(s.Ne,m,Math.max(1,e.a.size)),c=e.m,d=e.J,b=e.me,g=e.d.length>0;if(g)for(let x of e.d){let y=x.nodeStart+x.nodeCount;for(let C=x.nodeStart;C<y;C++){let _=d[C];_!==x.drillRoot&&Ja(e,t,_,l,m,f,x.centerX,x.centerY)}}else for(let x=0;x<b;x++){let y=d[x];y!==e.C&&Ja(e,t,y,l,m,f,e.dt,e.pt)}let h=Math.max(0,jn-s.jo*.5);if(t.fillStyle=u,t.textAlign=\"center\",t.textBaseline=\"middle\",g){for(let x of e.d)if(t.beginPath(),t.fillStyle=u,t.arc(x.centerX,x.centerY,h,0,2*Math.PI),t.fill(),t.fillStyle=a,t.font=`11px ${l}`,t.fillText(c.name[x.drillRoot],x.centerX,x.centerY),e.b){let y=e.b.cells.find(C=>C.label===x.label);y?.titleRect&&(t.fillStyle=a,t.font=`11px ${l}`,t.textBaseline=\"middle\",t.fillText(x.label,y.titleRect.x+y.titleRect.width/2,y.titleRect.y+y.titleRect.height/2))}}else t.beginPath(),t.arc(e.dt,e.pt,h,0,2*Math.PI),t.fill(),t.fillStyle=a,t.font=`11px ${l}`,t.fillText(c.name[e.C],e.dt,e.pt);!g&&e.pe.length>1&&wo(e,t,i,l,a),Ro(e,r,f,m,s,i,o,g?e.b?.legendRect??null:null),t.restore()}function Ja(e,t,n,i,o,r,s,l){let a=e.m,u=a.a0[n],m=a.a1[n],f=a.r0[n],c=a.r1[n],d=c-f,b=(f+c)/2,h=(m-u)*b;if(d<16||h<8)return;let x=Math.min(11,Math.floor(h*.7));if(x<7)return;t.font=`${x}px ${i}`;let y=a.name[n],C=d-4,_=y;if(t.measureText(_).width>C){for(;_.length>1;)if(_=_.slice(0,-1),t.measureText(_+\"\\u2026\").width<=C){_+=\"\\u2026\";break}}if(_.length<2)return;let v=(u+m)/2;t.save(),t.translate(s,l);let A=v,L=v>Math.PI/2&&v<3*Math.PI/2;e.lr===\"upright\"&&L&&(A+=Math.PI),t.rotate(A);let T=Xn(e,n,o,r),w=Ao(T[0],T[1],T[2]);t.fillStyle=w>.5?\"rgba(0,0,0,0.85)\":\"rgba(255,255,255,0.9)\",t.textAlign=\"center\",t.textBaseline=\"middle\";let M=e.lr===\"upright\"&&L?-b:b;t.fillText(_,M,0),t.restore()}function wc(e,t,n){let i=t.m,o=i.a0[n],r=i.a1[n],s=i.r0[n],l=i.r1[n],{centerX:a,centerY:u}=Go(t,n);e.strokeStyle=\"rgba(255,255,255,0.9)\",e.lineWidth=2,e.beginPath(),e.arc(a,u,l,o,r),e.arc(a,u,s,r,o,!0),e.closePath(),e.stroke()}function Mc(e,t,n,i,o,r){let s=e.m,l=(s.a0[n]+s.a1[n])/2,a=(s.r0[n]+s.r1[n])/2,{centerX:u,centerY:m}=Go(e,n),f=u+Math.cos(l)*a,c=m+Math.sin(l)*a;Mo(e,t,n,f,c,i,o,r)}function eu(e,t,n){if(e.d.length===0)return{centerX:e.dt,centerY:e.pt,drillRoot:e.C};for(let i of e.d){let o=t-i.centerX,r=n-i.centerY;if(!(Math.sqrt(o*o+r*r)>i.maxRadius+4))return{centerX:i.centerX,centerY:i.centerY,drillRoot:i.drillRoot}}return null}function Rc(e,t,n){let i=e.m,o=t;for(;o!==-1;){if(o===n)return!0;o=i.parent[o]}return!1}function tu(e,t,n){let i=eu(e,t,n);if(!i)return-1;let o=e.m,r=e.J,s=e.me;if(!r)return-1;let l=t-i.centerX,a=n-i.centerY,u=Math.sqrt(l*l+a*a),m=Math.atan2(a,l);if(m<0&&(m+=2*Math.PI),u<o.r1[e.K]+.001&&i.drillRoot!==e.K)return i.drillRoot;let f=e.d.length>0;for(let c=0;c<s;c++){let d=r[c];if(d===i.drillRoot||f&&!Rc(e,d,i.drillRoot))continue;let b=o.a0[d],g=o.a1[d],h=o.r0[d],x=o.r1[d];if(!(u<h||u>x)&&!(m<b||m>g))return d}return-1}function nu(e,t,n){if(e.fe!==-1)return;for(let r of e.qe)if(t>=r.x0&&t<=r.x1&&n>=r.y0&&n<=r.y1){e.w.setCursor(\"pointer\"),e.G!==-1&&(e.G=-1,mt(e));return}let i=tu(e,t,n),o=e.m;if(e.w.setCursor(i!==-1&&o.firstChild[i]!==-1?\"pointer\":\"default\"),i!==e.G){if(e.G=i,i!==-1){let r=e.U.beginHover(i);It(e,i).then(s=>{e.U.commitHover(r,s)&&mt(e)})}else e.U.clearHover();mt(e)}}function iu(e,t,n){if(e.fe!==-1){Wo(e),e.emitUnselect();return}for(let s of e.qe)if(t>=s.x0&&t<=s.x1&&n>=s.y0&&n<=s.y1){s.nodeId!==e.C&&(bs(e,s.nodeId),e.emitUnselect());return}let i=e.m,o=eu(e,t,n);if(o){let s=t-o.centerX,l=n-o.centerY;if(Math.sqrt(s*s+l*l)<i.r1[e.K]+.001){let u=i.parent[o.drillRoot];if(u!==-1&&u!==e.K)bs(e,u),e.emitUnselect();else if(e.d.length>0){let m=e.d.find(f=>f.drillRoot===o.drillRoot);m&&(e.ct.delete(m.label),e.emitUnselect()),e.i&&e.requestRender(e.i)}return}}let r=tu(e,t,n);r!==-1&&(i.firstChild[r]!==-1?(bs(e,r),Ze(e,r,\"branch\")):(Fc(e,r),Ze(e,r,\"leaf\")))}function bs(e,t){Io(e,t,()=>{e.i&&e.requestRender(e.i)})}function Fc(e,t){let n=e.m,i=(n.a0[t]+n.a1[t])/2,o=(n.r0[t]+n.r1[t])/2,{centerX:r,centerY:s}=Go(e,t),l=r+Math.cos(i)*o,a=s+Math.sin(i)*o;So(e,t,{cx:l,cy:a},()=>mt(e))}function Wo(e){Do(e)}var ko=class extends rn{constructor(){super(...arguments);p(this,\"o\",null);p(this,\"E\",null);p(this,\"hn\",null);p(this,\"xn\",null);p(this,\"bo\",0);p(this,\"lr\",\"upright\");p(this,\"dt\",0);p(this,\"pt\",0);p(this,\"po\",0);p(this,\"G\",-1);p(this,\"fe\",-1);p(this,\"qe\",[]);p(this,\"be\",null);p(this,\"Tt\",!0);p(this,\"On\",0);p(this,\"b\",null);p(this,\"ct\",new Map);p(this,\"d\",[])}tooltipCallbacks(){return{onHover:(n,i)=>nu(this,n,i),onLeave:()=>{this.G!==-1&&this.fe===-1&&(this.G=-1,mt(this))},onClickPre:(n,i)=>(iu(this,n,i),!0)}}async uploadAndRender(n,i,o,r){if(this.i=n,o===0){let s=this.L;if(this.re=s[0]||ho(i)||\"\",this.s=s[1]||\"\",!this.s)this.ue=\"empty\";else{let l=this.je[this.s],a=l===\"float\"||l===\"integer\"||l===\"date\"||l===\"datetime\";this.ue=a?\"numeric\":\"series\"}this.G=-1,this.fe=-1,this.qe=[],this.ct.clear(),this.b=null,this.d=[],this.bo=0,this.U.clearHover(),this.U.invalidatePin(),Wo(this),this.be?.close(),this.be=null,this.Tt=!0,this.On++,Hn(this)}Vn(this,i),zn(this),this.K!==-1&&await this.requestRender(n)}kt(n){this.K!==-1&&(this.i=n,Qa(this,n))}destroyInternal(){Wo(this),this.be?.close(),this.be=null;let n=this.i?.gl;n&&(this.hn&&n.deleteBuffer(this.hn),this.xn&&n.deleteBuffer(this.xn)),this.hn=null,this.xn=null,this.o=null,this.E=null,this.K=-1,this.C=-1,this.pe=[],this.Vt.clear(),this.J=null,this.me=0,this.qe=[],this.b=null,this.ct.clear(),this.d=[]}};Ln();var un=class extends De{constructor(){super(...arguments);p(this,\"Ie\",[]);p(this,\"ie\",0);p(this,\"bt\",0);p(this,\"o\",null);p(this,\"H\",null);p(this,\"u\",null);p(this,\"le\",null);p(this,\"te\",null);p(this,\"ae\",null);p(this,\"Ci\",!0)}getZoomConfig(){return{lockAxis:\"y\"}}};Tn();function No(e,t=.5,n=.1){let i=t/Math.max(1,e),o=i*(1-n)/2;return{slotWidth:i,halfWidth:o}}ge();function ou(e,t,n=\"bar\"){let i=t?.[e]?.chart_type?.toLowerCase?.();return i===\"bar\"||i===\"line\"||i===\"scatter\"||i===\"area\"?i:n}function ru(e,t,n){let i=n?.[e]?.stack;return typeof i==\"boolean\"?i:t===\"bar\"||t===\"area\"}function gs(e,t){return t?.[e]?.alt_axis===!0}function su(e,t,n){let i=n?.[e.aggName];if(!i)return null;let o=typeof i.palette==\"string\"?Sc(i.palette):null;if(o&&o.length>0){let r=t?0:e.splitIdx%o.length;return o[r]}return typeof i.color==\"string\"?Nr(i.color)??null:null}var Oo=new Map;function Sc(e){let t=Oo.get(e);return t===void 0&&(t=Ui(e),Oo.size>256&&Oo.clear(),Oo.set(e,t)),t}function lu(e,t,n){if(t!==\"line\"&&t!==\"area\")return\"skip\";let i=n?.[e]?.interpolate;return i===void 0||t===\"area\"?\"solid\":i}var au=50,Et=0,Uo=1;function Ho(){return{count:0,catIdx:new Int32Array(0),seriesId:new Int32Array(0),axis:new Uint8Array(0),chartType:new Uint8Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),y0:new Float64Array(0),y1:new Float64Array(0)}}function Dc(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),seriesId:new Int32Array(t),axis:new Uint8Array(t),chartType:new Uint8Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),y0:new Float64Array(t),y1:new Float64Array(t)}}function Zn(e,t,n,i,o){let r=e.seriesId[t],s=e.catIdx[t];return{catIdx:s,aggIdx:Math.floor(r/n),splitIdx:r%n,seriesId:r,xCenter:e.xCenter[t],halfWidth:e.halfWidth[t],y0:e.y0[t],y1:e.y1[t],value:i[s*o+r],axis:e.axis[t],chartType:e.chartType[t]===Et?\"bar\":\"area\"}}function uu(e,t){return e&&e.length>=t?e:new Float64Array(Math.max(t,e?.length??0))}function mu(e,t){e[t>>3]|=1<<(t&7)}function fu(e){let{columns:t,numRows:n,columnSlots:i,groupBy:o,splitBy:r,groupByTypes:s,columnsConfig:l,defaultChartType:a,autoAltYAxis:u,bandInnerFrac:m,barInnerPad:f,includeZero:c,facetSplits:d,scratchBars:b,scratchPosStack:g,scratchNegStack:h}=e,x=sn(o,s),y={aggregates:[],splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:x,numericCategoryDomain:null,categoryPositions:null,series:[],bars:Ho(),posStack:g??null,negStack:h??null,samples:new Float32Array(0),sampleValid:new Uint8Array(0),leftDomain:{min:0,max:0},rightDomain:null,hasRightAxis:!1,leftValueAxisMode:\"numeric\",rightValueAxisMode:null,leftValueCategoryDomain:null,rightValueCategoryDomain:null},C=i.filter(R=>!!R);if(C.length===0)return y;let _=[];if(r.length>0){for(let R of it(t,[],C))R.colNames.size>0&&_.push(R.prefix);_.length===0&&_.push(\"\")}else _.push(\"\");let v=o.map(R=>s[R]??\"string\"),{rowPaths:A,numCategories:L,rowOffset:T}=ln(t,n,o.length,v,x);if(L===0)return{...y,rowPaths:A,rowOffset:T};let w=[],M=C.length,I=_.length;for(let R=0;R<M;R++)for(let P=0;P<I;P++){let B=C[R],O=_[P],X=O===\"\"?B:`${O}${M>1?` | ${B}`:\"\"}`,z=ou(B,l,a),Z=ru(B,z,l),ye=lu(B,z,l);w.push({seriesId:R*I+P,aggIdx:R,splitIdx:P,aggName:B,splitKey:O,label:X,color:[.5,.5,.5],axis:0,chartType:z,stack:Z,start:-1,end:-1,interpolateMode:ye})}let D=[];for(let R=0;R<M;R++)D.push(c?{min:0,max:0}:{min:1/0,max:-1/0});let S=L,E=w.length,k=d?S*M*I:S*M,W=uu(g??null,k),V=uu(h??null,k);W.fill(0,0,k),V.fill(0,0,k);let N=new Float32Array(S*E),H=new Uint8Array(S*E+7>>3),U=null,Y=null,q=1;if(x.mode===\"numeric\"&&S>0){let R=t.get(\"__ROW_PATH_0__\"),P=Dt(R?.values,S,T,o[0]??\"\",x.numericType===\"date\"||x.numericType===\"datetime\");P&&(U=P.categoryPositions,Y=P.numericCategoryDomain,q=P.numericCategoryDomain.bandWidth)}let me=No(M,m,f),Ge=me.slotWidth*q,Re=me.halfWidth*q,Fe=new Float64Array(M),pt=(M-1)/2;for(let R=0;R<M;R++)Fe[R]=(R-pt)*Ge;let bn=new Array(M*I),gn=new Array(M*I);for(let R=0;R<M;R++){let P=C[R];for(let B=0;B<I;B++){let O=_[B],X=O===\"\"?P:`${O}|${P}`,z=t.get(X),Z=R*I+B;bn[Z]=z?.values??null,gn[Z]=z?.valid??null}}let hn=new Array(M),Ae=new Array(M),ae=!1;for(let R=0;R<M;R++){let P=C[R],B=_[0],O=B===\"\"?P:`${B}|${P}`;hn[R]=t.get(O)?.type===\"string\",Ae[R]=gs(P,l)?1:0,hn[R]&&(ae=!0)}let ee=[],re=[],We=[],ke=[];for(let R=0;R<M;R++){let P=C[R];for(let B=0;B<I;B++){let O=_[B],X=O===\"\"?P:`${O}|${P}`,z=R*I+B,Z={name:X,type:hn[R]?\"string\":\"numeric\",data:t.get(X)};Ae[R]===0?(ee.push(Z),We.push(z)):(re.push(Z),ke.push(z))}}let Ys=ee.map(R=>R.name).filter((R,P,B)=>B.indexOf(R)===P).join(\", \"),dr=re.map(R=>R.name).filter((R,P,B)=>B.indexOf(R)===P).join(\", \"),Ne=ee.length>0?ls(ee,n,T,Ys):null,J=re.length>0?ls(re,n,T,dr):null,Pt=new Array(M*I).fill(null);if(Ne)for(let R=0;R<We.length;R++)Pt[We[R]]=Ne.perColumnSlots[R];if(J)for(let R=0;R<ke.length;R++)Pt[ke[R]]=J.perColumnSlots[R];let nm=S*M*I,$=Dc(b??null,nm),te=0;for(let R=0;R<S;R++){let P=R+T;for(let B=0;B<M;B++)for(let O=0;O<I;O++){let X=B*I+O,z=Pt[X];if(z){let ue=B*I+O,Le=R*E+ue;N[Le]=z[R],mu(H,Le);continue}let Z=bn[X];if(!Z)continue;let ye=gn[X];if(ye&&!(ye[P>>3]>>(P&7)&1))continue;let ne=Z[P];if(!isFinite(ne))continue;let Gt=B*I+O,gt=R*E+Gt;N[gt]=ne,mu(H,gt)}}for(let R=0;R<E;R++){let P=-1,B=-1;for(let O=0;O<S;O++){let X=O*E+R;H[X>>3]>>(X&7)&1&&(P===-1&&(P=O),B=O)}w[R].start=P,w[R].end=B}for(let R=0;R<E;R++){let P=w[R];if(!(P.start<0)&&P.interpolateMode!==\"skip\"){if(P.chartType===\"line\"){let B=P.start;for(let O=P.start+1;O<=P.end;O++){let X=O*E+R;if(H[X>>3]>>(X&7)&1){if(O-B>1){let Z=B*E+R,ye=N[Z],ne=N[X],Gt=U?U[B]:B,ue=(U?U[O]:O)-Gt;for(let Le=1;Le<O-B;Le++){let pe=B+Le,Te=U?U[pe]:pe,um=ue===0?0:(Te-Gt)/ue;N[pe*E+R]=ye+(ne-ye)*um}}B=O}}}else if(P.chartType===\"area\"){for(let B=0;B<P.start;B++)N[B*E+R]=0;for(let B=P.end+1;B<S;B++)N[B*E+R]=0;P.start=0,P.end=S-1}}}for(let R=0;R<S;R++){let P=U?U[R]:R;for(let B=0;B<M;B++){let O=Fe[B],X=P+O,z=D[B];for(let Z=0;Z<I;Z++){let ye=B*I+Z,ne=w[ye];if(R<ne.start||R>ne.end)continue;let Gt=ne.chartType===\"line\"||ne.chartType===\"area\"&&ne.interpolateMode!==\"skip\",gt=R*E+ye;if(!Gt&&!(H[gt>>3]>>(gt&7)&1))continue;let ue=N[gt];if((ne.chartType===\"bar\"||ne.chartType===\"area\")&&ne.stack){if(ue===0&&(ne.chartType!==\"area\"||ne.interpolateMode===\"skip\"))continue;let Le=d?(R*M+B)*I+Z:R*M+B,pe,Te;ue>=0?(pe=W[Le],Te=pe+ue,W[Le]=Te):(pe=V[Le],Te=pe+ue,V[Le]=Te),pe<z.min&&(z.min=pe),Te<z.min&&(z.min=Te),pe>z.max&&(z.max=pe),Te>z.max&&(z.max=Te),$.catIdx[te]=R,$.seriesId[te]=ye,$.axis[te]=0,$.chartType[te]=ne.chartType===\"bar\"?Et:Uo,$.xCenter[te]=X,$.halfWidth[te]=Re,$.y0[te]=pe,$.y1[te]=Te,te++}else if(ue<z.min&&(z.min=ue),ue>z.max&&(z.max=ue),c&&(0<z.min&&(z.min=0),0>z.max&&(z.max=0)),ne.chartType===\"bar\"||ne.chartType===\"area\"){if(ue===0)continue;$.catIdx[te]=R,$.seriesId[te]=ye,$.axis[te]=0,$.chartType[te]=ne.chartType===\"bar\"?Et:Uo,$.xCenter[te]=X,$.halfWidth[te]=Re,$.y0[te]=0,$.y1[te]=ue,te++}}}}$.count=te;let Bt=!1;if(u&&M>=2&&!ae){let R=new Array(M),P=0,B=1/0;for(let O=0;O<M;O++){let X=D[O],z=Math.max(Math.abs(X.min),Math.abs(X.max),1e-12);R[O]=z,z>P&&(P=z),z<B&&(B=z)}if(P/B>au){let O=P/Math.sqrt(au);for(let X=0;X<M;X++)if(R[X]<O)for(let Z of w)Z.aggIdx===X&&(Z.axis=1);for(let X=0;X<$.count;X++)$.axis[X]=w[$.seriesId[X]].axis;Bt=w.some(X=>X.axis===1)}}let Xs=!1;for(let R=0;R<M;R++)if(gs(C[R],l))for(let P of w)P.aggIdx===R&&(P.axis=1,Xs=!0);if(Xs){for(let R=0;R<$.count;R++)$.axis[R]=w[$.seriesId[R]].axis;Bt=!0}let Oe=c?{min:0,max:0}:{min:1/0,max:-1/0},bt=c?{min:0,max:0}:{min:1/0,max:-1/0};for(let R=0;R<$.count;R++){let P=$.axis[R]===0?Oe:bt,B=$.y0[R],O=$.y1[R];B<P.min&&(P.min=B),O<P.min&&(P.min=O),B>P.max&&(P.max=B),O>P.max&&(P.max=O)}for(let R=0;R<E;R++){let P=w[R];if(P.stack&&(P.chartType===\"bar\"||P.chartType===\"area\")||P.start<0)continue;let B=P.chartType===\"line\"||P.chartType===\"area\"&&P.interpolateMode!==\"skip\",O=P.axis===0?Oe:bt;for(let X=P.start;X<=P.end;X++){let z=X*E+R;if(!B&&!(H[z>>3]>>(z&7)&1))continue;let Z=N[z];Z<O.min&&(O.min=Z),Z>O.max&&(O.max=Z)}}(!isFinite(Oe.min)||!isFinite(Oe.max)||Oe.min===0&&Oe.max===0)&&(Oe.min=0,Oe.max=1);let im=!isFinite(bt.min)||!isFinite(bt.max)||bt.min===0&&bt.max===0,om=Bt?im?{min:0,max:1}:bt:null,rm=Ne?\"category\":\"numeric\",sm=Bt?J?\"category\":\"numeric\":null,lm=Ne&&Ne.domain.numRows>0?{min:0,max:Math.max(0,Ne.domain.numRows-1)}:Oe,am=J&&J.domain.numRows>0&&Bt?{min:0,max:Math.max(0,J.domain.numRows-1)}:om;return{aggregates:C,splitPrefixes:_,rowPaths:A,numCategories:L,rowOffset:T,axisMode:x,numericCategoryDomain:Y,categoryPositions:U,series:w,bars:$,posStack:W,negStack:V,samples:N,sampleValid:H,leftDomain:lm,rightDomain:am,hasRightAxis:Bt,leftValueAxisMode:rm,rightValueAxisMode:sm,leftValueCategoryDomain:Ne?.domain??null,rightValueCategoryDomain:J?.domain??null}}ot();Fn();Nt();be();Dn();Be();var hs=Et;function cu(e,t,n,i){let o=i?.start??0,r=i?.count??e.Un;if(e.Un===0||r===0)return;let s=e.E,l=Q(n),{setDivisor:a}=l;t.bindBuffer(t.ARRAY_BUFFER,e.H),t.enableVertexAttribArray(s.a_corner),t.vertexAttribPointer(s.a_corner,2,t.FLOAT,!1,0,0),a(s.a_corner,0),ut(n,l,s.a_x_center,\"bar_x\",1,o)&&ut(n,l,s.a_half_width,\"bar_hw\",1,o)&&ut(n,l,s.a_y0,\"bar_y0\",1,o)&&ut(n,l,s.a_y1,\"bar_y1\",1,o)&&ut(n,l,s.a_color,\"bar_color\",3,o)&&ut(n,l,s.a_series_id,\"bar_sid\",1,o)&&ut(n,l,s.a_axis,\"bar_axis\",1,o)&&l.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,r),a(s.a_x_center,0),a(s.a_half_width,0),a(s.a_y0,0),a(s.a_y1,0),a(s.a_color,0),a(s.a_series_id,0),a(s.a_axis,0)}be();var Vo=10;function mn(e){return e.Ee>=0?Zn(e.Ae,e.Ee,e.ge.length,e.et,e.f.length):e.Pe}function xs(e,t,n){if(!e.u)return;let i=e.u,o;if(e.b){let _=e.b.cells,v=-1;for(let A=0;A<_.length;A++){let L=_[A].layout.e;if(t>=L.x&&t<=L.x+L.width&&n>=L.y&&n<=L.y+L.height){v=A;break}}if(v<0){du(e);return}i=_[v].layout,o=v}let r=i.e;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){du(e);return}let s=i.O,l=i.Z,a=i.q,u=i.ee,m,f,c,d;if(e.Be){let _=s,v=l,A=Math.min(a,u),L=Math.max(a,u),T=_+(t-r.x)/r.width*(v-_);m=A+(n-r.y)/r.height*(L-A),f=T,c=r.height/(L-A),d=r.width/(v-_)}else m=s+(t-r.x)/r.width*(l-s),f=u-(n-r.y)/r.height*(u-a),c=r.width/(l-s),d=r.height/(u-a);let b=e.yn&&e.oe&&!e.Be?e.oe.max-(n-r.y)/r.height*(e.oe.max-e.oe.min):f,g=e.yn&&e.oe&&!e.Be?r.height/(e.oe.max-e.oe.min):d,h=-1,x=null,y=e.Xt,C=y.length<=1;for(let _=y.length-1;_>=0;_--){let v=y[_],A=C?void 0:{start:v.aggStart,end:v.aggEnd};switch(v.chartType){case\"scatter\":case\"line\":x=Ec(e,v.chartType,m,f,b,c,d,g,o,A);break;case\"bar\":h=Ic(e,m,f,b,o,A);break;case\"area\":{let L=Pc(e,m,f,b,o,A);L&&(L.idx>=0?h=L.idx:x=L.bar);break}}if(h>=0||x)break}Bc(e,h,x)}function Ic(e,t,n,i,o,r){let s=e.Ae,l=s.chartType,a=s.seriesId,u=s.xCenter,m=s.halfWidth,f=s.y0,c=s.y1,d=s.axis,b=e.ne,g=Math.max(1,e.ge.length);for(let h=0;h<s.count;h++){if(l[h]!==Et||b.has(a[h])||o!==void 0&&a[h]%g!==o)continue;if(r!==void 0){let T=Math.floor(a[h]/g);if(T<r.start||T>r.end)continue}let x=u[h],y=m[h];if(t<x-y||t>x+y)continue;let C=d[h]===0?n:i,_=f[h],v=c[h],A=_<v?_:v,L=_<v?v:_;if(C>=A&&C<=L)return h}return-1}function Ec(e,t,n,i,o,r,s,l,a,u){let m=e.ie,f=e.f.length;if(m===0||f===0)return null;let c=e.et,d=e.$t,g=Vo*Vo,h=null,x=e.V;for(let y of e.f){if(y.chartType!==t||e.ne.has(y.seriesId)||a!==void 0&&y.splitIdx!==a||u!==void 0&&(y.aggIdx<u.start||y.aggIdx>u.end))continue;let C=y.axis===1?o:i,_=y.axis===1?l:s,v=x?0:Math.max(0,Math.floor(n-Vo/r)),A=x?m-1:Math.min(m-1,Math.ceil(n+Vo/r));for(let L=v;L<=A;L++){let T=L*f+y.seriesId;if(!(d[T>>3]>>(T&7)&1))continue;let w=c[T],M=x?x[L]:L,I=(M-n)*r,D=(w-C)*_,S=I*I+D*D;S<g&&(g=S,h={catIdx:L,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:M,halfWidth:0,y0:0,y1:w,value:w,axis:y.axis,chartType:\"bar\"})}}return h}function Pc(e,t,n,i,o,r){let s=Math.round(t);if(s<0||s>=e.ie||Math.abs(t-s)>.5)return null;let l=e.f.length,a=e.et,u=e.$t,m=e.Ae,f=m.chartType,c=m.catIdx,d=m.seriesId,b=m.axis,g=m.y0,h=m.y1,x=e.ge.length;for(let y=0;y<m.count;y++){if(f[y]!==Uo||c[y]!==s||e.ne.has(d[y])||o!==void 0&&d[y]%x!==o)continue;if(r!==void 0){let T=Math.floor(d[y]/Math.max(1,x));if(T<r.start||T>r.end)continue}let C=b[y]===0?n:i,_=g[y],v=h[y],A=_<v?_:v,L=_<v?v:_;if(C>=A&&C<=L)return{idx:y,bar:null}}for(let y of e.f){if(y.chartType!==\"area\"||y.stack||e.ne.has(y.seriesId)||o!==void 0&&y.splitIdx!==o||r!==void 0&&(y.aggIdx<r.start||y.aggIdx>r.end))continue;let C=s*l+y.seriesId;if(!(u[C>>3]>>(C&7)&1))continue;let _=a[C],v=y.axis===1?i:n,A=Math.min(0,_),L=Math.max(0,_);if(v>=A&&v<=L)return{idx:-1,bar:{catIdx:s,aggIdx:y.aggIdx,splitIdx:y.splitIdx,seriesId:y.seriesId,xCenter:s,halfWidth:.5,y0:0,y1:_,value:_,axis:y.axis,chartType:\"area\"}}}return null}function du(e){(e.Ee!==-1||e.Pe!==null)&&(e.Ee=-1,e.Pe=null,e.i&&e.requestRender(e.i))}function Bc(e,t,n){let i=e.Ee===t,o=(e.Pe?.seriesId??-1)===(n?.seriesId??-1)&&(e.Pe?.catIdx??-1)===(n?.catIdx??-1);i&&o||(e.Ee=t,e.Pe=n,e.i&&e.requestRender(e.i))}function pu(e,t,n){if(e._n.length===0)return!1;for(let i of e._n){let o=i.rect;if(t>=o.x&&t<=o.x+o.width&&n>=o.y&&n<=o.y+o.height){let r=i.seriesIds.some(s=>!e.ne.has(s));for(let s of i.seriesIds)r?e.ne.add(s):e.ne.delete(s);return e.wt=null,e.ar=!1,e.Ii=null,e.i&&(zo(e,e.i),Yo(e,e.i),e.requestRender(e.i)),!0}}return!1}function ys(e,t){let n=[],i=e.f[t.seriesId],o=_s(e,t.catIdx);o&&n.push([o]);let r=e.getColumnFormatter(i.aggName,\"value\");return n.push([i.aggName,r(t.value)]),i.splitKey&&n.push([\"Split\",i.splitKey]),t.y0!==0&&(n.push([\"Base\",r(t.y0)]),n.push([\"Top\",r(t.y1)])),n}function _s(e,t){if(e.Le===\"numeric\"&&e.V){let i=e.V[t];if(i==null)return\"\";let o=e.h[0];return e.getColumnFormatter(o,\"value\")(i)}if(e.Ie.length===0)return\"\";let n=[];for(let i of e.Ie){let o=i.labels[t];o!=null&&o!==\"\"&&n.push(o)}return n.join(\" / \")}function bu(e,t){t<0||t>=e.Ae.count||(e.go=t,hu(e,Zn(e.Ae,t,e.ge.length,e.et,e.f.length)))}function gu(e,t){e.go=-1,hu(e,t)}function hu(e,t){if(e.w.dismiss(),!e.u)return;let n=Cs(e,t);if(!n)return;let o=(e.f[t.seriesId]?.chartType??\"bar\")===\"bar\"?(t.y0+t.y1)/2:t.y1,r=t.axis===0?e.Be?n.R(o,t.xCenter):n.R(t.xCenter,o):Xo(e,t.xCenter,o,n),s=ys(e,t);s.length!==0&&(e.w.pin(s,r,n,ie(e.t)),e.Ee=-1,e.Pe=null,e.i&&e.requestRender(e.i))}Ce();Hr();Ce();Tt();Jt();Ki();function xu(e,t,n){return n||fe(e.isDate,t)}function vs(e,t,n,i,o,r,s){let{Fe:l,fontFamily:a}=r,{e:u}=t,m=o===\"bottom\"?u.y+u.height:u.y;e.fillStyle=l,e.font=`11px ${a}`,e.lineWidth=1,Zi(e,u,i,m,o,f=>t.R(f,0).px,xu(n,i,s)),e.font=`13px ${a}`,e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(n.label,u.x+u.width/2,o===\"bottom\"?t.cssHeight-2:10)}function As(e,t,n,i,o,r,s){let{Fe:l,fontFamily:a}=r,{e:u}=t,m=o===\"left\"?u.x:u.x+u.width;e.fillStyle=l,e.font=`11px ${a}`,e.lineWidth=1,qi(e,u,i,m,o,f=>t.R(0,f).py,xu(n,i,s)),e.font=`13px ${a}`,e.save(),o===\"left\"?(e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2)):(e.translate(t.cssWidth-10,u.y+u.height/2),e.rotate(Math.PI/2)),e.textAlign=\"center\",e.textBaseline=\"bottom\",e.fillText(n.label,0,0),e.restore()}function $o(e,t,n,i,o,r){vs(e,t,n,i,\"bottom\",o,r)}function jo(e,t,n,i,o,r){As(e,t,n,i,\"left\",o,r)}function Zo(e,t,n,i,o,r,s,l=!1,a={}){let u=ce(e,i,r);if(!u)return;let{e:m}=i;if(u.strokeStyle=o.di,u.lineWidth=1,u.beginPath(),u.moveTo(m.x,m.y),u.lineTo(m.x,m.y+m.height),u.lineTo(m.x+m.width,m.y+m.height),s&&(l?(u.moveTo(m.x,m.y),u.lineTo(m.x+m.width,m.y)):(u.moveTo(m.x+m.width,m.y),u.lineTo(m.x+m.width,m.y+m.height))),u.stroke(),l){if(t.mode===\"category\"?Pe(u,i,t.domain,o):jo(u,i,t.domain,t.ticks,o,a.category),n.mode===\"category\"?xe(u,i,n.domain,o):vs(u,i,n.domain,n.ticks,\"bottom\",o,a.value),s)if(s.mode===\"category\")xe(u,i,s.domain,o);else{let f=i.O,c=i.Z;i.O=s.domain.min,i.Z=s.domain.max,vs(u,i,s.domain,s.ticks,\"top\",o,a.alt),i.O=f,i.Z=c}}else if(t.mode===\"category\"?xe(u,i,t.domain,o):$o(u,i,t.domain,t.ticks,o,a.category),n.mode===\"category\"?Pe(u,i,n.domain,o):As(u,i,n.domain,n.ticks,\"left\",o,a.value),s)if(s.mode===\"category\")Pe(u,i,s.domain,o);else{let f=i.q,c=i.ee;i.q=s.domain.min,i.ee=s.domain.max,As(u,i,s.domain,s.ticks,\"right\",o,a.alt),i.q=f,i.ee=c}}function qo(e,t,n,i,o,r=!1){let s=ce(e,t,o);s&&(s.strokeStyle=i.Rn,s.lineWidth=1,r?Xt(s,t.e,n,l=>t.R(l,0).px):$t(s,t.e,n,l=>t.R(0,l).py))}Jt();Ht();ji();Tt();Ki();Nn();Ve();var ft=null;function yu(e){if(ft&&ft.xCenters.length>=e&&ft.colors.length>=e*3)return ft;let t=Math.max(e,ft?.xCenters.length??0);return ft={xCenters:new Float32Array(t),halfWidths:new Float32Array(t),y0s:new Float32Array(t),y1s:new Float32Array(t),seriesIds:new Float32Array(t),axes:new Float32Array(t),colors:new Float32Array(t*3)},ft}function zo(e,t){let n=e.Ae,i=n.count,o=e.ge.length,r=e.jt&&o>0,s=0;if(e.Ei=null,e.Hn=null,e.Vn=null,i>0){let a=yu(i);(!e.zn||e.zn.length<i)&&(e.zn=new Int32Array(i));let u=e.zn,m=e.ce,f=e.f,c=e.ne,d=n.chartType,b=n.seriesId,g=n.xCenter,h=n.halfWidth,x=n.y0,y=n.y1,C=n.axis,_=Math.max(1,e.tt.length),v=r?D=>D%o*_+Math.floor(D/o):D=>o>0?Math.floor(D/o):D,A=r?o*_:_,L=new Array(A).fill(0);for(let D=0;D<i;D++)d[D]!==hs||c.has(b[D])||L[v(b[D])]++;let T=[],w=new Int32Array(A),M=0;for(let D=0;D<A;D++)T.push({start:M,count:L[D]}),w[D]=M,M+=L[D];r?(e.Vn=null,e.Hn=Array.from({length:o},(D,S)=>T.slice(S*_,(S+1)*_)),e.Ei=Array.from({length:o},(D,S)=>{let E=T[S*_],k=T[(S+1)*_-1];return{start:E.start,count:k.start+k.count-E.start}})):(e.Vn=T,e.Hn=null);let I=D=>w[v(D)]++;for(let D=0;D<i;D++){if(d[D]!==hs)continue;let S=b[D];if(c.has(S))continue;let E=I(S);a.xCenters[E]=g[D]-m,a.halfWidths[E]=h[D],a.y0s[E]=x[D],a.y1s[E]=y[D],a.seriesIds[E]=S,a.axes[E]=C[D];let k=f[S].color;a.colors[E*3]=k[0],a.colors[E*3+1]=k[1],a.colors[E*3+2]=k[2],u[E]=D,s++}}else r&&(e.Ei=Array.from({length:o},()=>({start:0,count:0})));if(e.Un=s,s===0){e.Je=null;return}let l=ft;t.A.ensureCapacity(s),t.A.upload(\"bar_x\",l.xCenters.subarray(0,s),0,1),t.A.upload(\"bar_hw\",l.halfWidths.subarray(0,s),0,1),t.A.upload(\"bar_y0\",l.y0s.subarray(0,s),0,1),t.A.upload(\"bar_y1\",l.y1s.subarray(0,s),0,1),t.A.upload(\"bar_sid\",l.seriesIds.subarray(0,s),0,1),t.A.upload(\"bar_axis\",l.axes.subarray(0,s),0,1),t.A.upload(\"bar_color\",l.colors.subarray(0,s*3),0,3),(!e.Je||e.Je.length<s*3)&&(e.Je=new Float32Array(Math.max(s*3,e.Je?.length??0))),e.Je.set(l.colors.subarray(0,s*3))}function Gc(e,t){let n=e.Un;if(n===0)return;let i=e.zn,o=e.f,r=e.Ae.seriesId,s=yu(n);for(let a=0;a<n;a++){let u=o[r[i[a]]].color;s.colors[a*3]=u[0],s.colors[a*3+1]=u[1],s.colors[a*3+2]=u[2]}let l=e.Je;if(l&&l.length>=n*3){let a=!0;for(let u=0;u<n*3;u++)if(l[u]!==s.colors[u]){a=!1;break}if(a)return}t.A.upload(\"bar_color\",s.colors.subarray(0,n*3),0,3),(!l||l.length<n*3)&&(e.Je=new Float32Array(n*3)),e.Je.set(s.colors.subarray(0,n*3))}function _u(e){e.Y.lines.invalidateBuffers(e),e.Y.scatter.invalidateBuffers(e),e.Y.areas.invalidateBuffers(e)}function Yo(e,t){e.Y.lines.rebuildBuffers(e,t),e.Y.scatter.rebuildBuffers(e,t),e.Y.areas.rebuildBuffers(e,t)}function Cu(e,t){let n=t.gl,i=t.dpr,o=n.canvas.width/i,r=n.canvas.height/i;if(o<=0||r<=0||e.ie===0)return;let s=e.v();Ls(e)&&e.Un>0&&Gc(e,t);let l=e.Be,a=e.Le===\"numeric\",u=a?e.I.min:-.5,m=a?e.I.max:e.ie-.5,f=e.ho.min,c=e.ho.max;e._&&(l?e._.setBaseDomain(f,c,u,m):e._.setBaseDomain(u,m,f,c));let d=u,b=m,g=f,h=c,x=e.oe?.min??0,y=e.oe?.max??1;if(e._){let H=e._.getVisibleDomain();l?(g=H.xMin,h=H.xMax,d=H.yMin,b=H.yMax):(d=H.xMin,b=H.xMax,g=H.yMin,h=H.yMax)}let C=l?!e._?.isYDefault():!e._?.isXDefault();if(e.Ci&&e._&&C){let H=zc(e,d,b);H.hasLeft&&(g=H.leftMin,h=H.leftMax),e.oe&&H.hasRight&&(x=H.rightMin,y=H.rightMax)}if(e.t.include_zero&&(g>0&&(g=0),h<0&&(h=0),e.oe&&(x>0&&(x=0),y<0&&(y=0))),e.jt&&e.ge.length>1){kc(e,t,{horizontal:l,numericCat:a,cssWidth:o,cssHeight:r,visCatMin:d,visCatMax:b,visValMin:g,visValMax:h,visRightMin:x,visRightMax:y});return}e.b=null;let _=e.f.length>1,v=e.h.length>0,A={levels:e.Ie,numRows:e.ie,levelLabels:e.h.slice()},L=e.Cn,T=e.Yn===\"category\"&&L!==null&&L.numRows>0,w;if(l){let H=a?55:Kt(A),U=H+(v?16:0),Y=nt(e.t,_,80,e.f.length),q=Math.max(1,o-U-Y),me=T?Xe(L,q):void 0;w=new oe(o,r,{hasXLabel:!0,hasYLabel:v,hasLegend:_,leftExtra:H,bottomExtra:me,rightExtra:Y})}else if(a){let H=T?Kt(L):void 0;w=new oe(o,r,{hasXLabel:v,hasYLabel:!0,hasLegend:_,bottomExtra:24,leftExtra:H,rightExtra:nt(e.t,_,80,e.f.length)})}else{let H=T?Kt(L):55,U=H+16,Y=nt(e.t,_,80,e.f.length),q=Math.max(1,o-U-Y),me=Xe(A,q);w=new oe(o,r,{hasXLabel:v,hasYLabel:!0,hasLegend:_,bottomExtra:me,leftExtra:T?H:void 0,rightExtra:Y})}e.u=w,e._&&e._.updateLayout(w);let M=e.t.include_zero,I=l?w.buildProjectionMatrix(g,h,b,d,\"x\",M,void 0,0,e.ce):w.buildProjectionMatrix(d,b,g,h,\"y\",M,void 0,e.ce,0),D;if(e.yn&&e.oe&&!l){let H=w.O,U=w.Z,Y=w.q,q=w.ee;D=w.buildProjectionMatrix(d,b,x,y,\"y\",M,void 0,e.ce,0),w.O=H,w.Z=U,w.q=Y,w.ee=q}else D=I;let S=K(g,h,6),E=e.yn&&e.oe&&!l?K(x,y,6):null,k=A,W={min:g,max:h,label:e.xo},V=e.oe&&!l?{min:x,max:y,label:e.ur}:null;e.Q&&qo(e.Q,w,S,s,t.dpr,l);let N=e.f.length>1?mn(e):null;rt(n,w,t.dpr,()=>{vu(e,n,t,I,D,s.pi,l,N?N.seriesId:-1)}),e.le=k,e.te=W,e.ae=S,e.Xn=V,e.$n=E,e.Ge=a?K(d,b,6):null,e._e(()=>Ko(e))}function vu(e,t,n,i,o,r,s,l,a){let u=e.Xt,m=u.length<=1;for(let f of u){let c=m?void 0:{start:f.aggStart,end:f.aggEnd};switch(f.chartType){case\"area\":s||e.Y.areas.draw(e,t,n,i,o,r,a,c);break;case\"bar\":{t.useProgram(e.o);let d=e.E;t.uniformMatrix4fv(d.u_proj_left,!1,i),t.uniformMatrix4fv(d.u_proj_right,!1,o),t.uniform1f(d.u_horizontal,s?1:0),t.uniform1f(d.u_hover_series,l),cu(e,t,n,Wc(e,f,a));break}case\"line\":s||e.Y.lines.draw(e,t,n,i,o,a,c);break;case\"scatter\":s||e.Y.scatter.draw(e,t,n,i,o,a,c);break}}}function Wc(e,t,n){let i=n!==void 0?e.Hn?.[n]:e.Vn;if(!i)return n!==void 0?{start:0,count:0}:void 0;let o=i[t.aggStart],r=i[t.aggEnd];return{start:o.start,count:r.start+r.count-o.start}}function kc(e,t,n){let i=t.gl,o=t.dpr,r=e.v(),{horizontal:s,numericCat:l,cssWidth:a,cssHeight:u,visCatMin:m,visCatMax:f,visValMin:c,visValMax:d,visRightMin:b,visRightMax:g}=n,h=e.h.length>0,x=e.Cn,y=e.Yn===\"category\"&&x!==null&&x.numRows>0,C=e.tt.length>1,_=l?\"outer\":\"cell\",v=y?\"cell\":\"outer\",A=Ie(e.ge,{cssWidth:a,cssHeight:u,xAxis:s?v:_,yAxis:s?_:v,hasLegend:C&&se(e.t,e.tt.length)===\"sidebar\",legendWidth:we(e.t,96),hasXLabel:s?!0:h,hasYLabel:s?h:!0,gap:e.W.facet_padding});if(e.b=A,e.u=A.cells[0]?.layout??null,A.cells.length===0||!e.u)return;e.syncFacetZoomLayouts(A.cells);let L=K(c,d,6),T=l?K(m,f,6):null,w=A.cells[0].layout,M=e.Q;M&&e._e(()=>ce(M,w,o));let I=e.t.include_zero,D=e.f.length>1?mn(e):null,S=e.yn&&e.oe!==null&&!s;At(i);for(let E=0;E<A.cells.length;E++){let W=A.cells[E].layout,V=s?W.buildProjectionMatrix(c,d,f,m,\"x\",I,void 0,0,e.ce):W.buildProjectionMatrix(m,f,c,d,\"y\",I,void 0,e.ce,0),N=V;if(S){let H=W.O,U=W.Z,Y=W.q,q=W.ee;N=W.buildProjectionMatrix(m,f,b,g,\"y\",I,void 0,e.ce,0),W.O=H,W.Z=U,W.q=Y,W.ee=q}M&&e._e(()=>Nc(M,W,L,r,o,s)),Lt(i,W,o,()=>{vu(e,i,t,V,N,r.pi,s,D&&D.splitIdx===E?D.seriesId:-1,E)})}e.le={levels:e.Ie,numRows:e.ie,levelLabels:e.h.slice()},e.te={min:c,max:d,label:e.xo},e.ae=L,e.Xn=null,e.$n=null,e.Ge=T,e._e(()=>Ko(e))}function Nc(e,t,n,i,o,r){let s=le(e,o);s&&(s.strokeStyle=i.Rn,s.lineWidth=1,r?Xt(s,t.e,n,l=>t.R(l,0).px):$t(s,t.e,n,l=>t.R(0,l).py))}function Cs(e,t){return e.b?e.b.cells[t.splitIdx]?.layout??null:e.u}function Ko(e){Oc(e),e.presentOverlay()}function Oc(e){if(!e.l||!e.u||!e.te||!e.ae)return;if(e.b){Uc(e);return}let t=e.v(),n;if(e.Le===\"numeric\"&&e.I&&e.Ge)n={mode:\"numeric\",domain:{min:e.I.min,max:e.I.max,isDate:e.I.isDate,label:e.I.label},ticks:e.Ge};else if(e.le)n={mode:\"category\",domain:e.le};else return;let i=e.f.find(a=>a.axis===0),o=e.f.find(a=>a.axis===1),r=e.h[0],s=e.Yn===\"category\"&&e.Cn?{mode:\"category\",domain:e.Cn}:{mode:\"numeric\",domain:e.te,ticks:e.ae},l;e.Xn&&e.$n&&(l=e.mr===\"category\"&&e.yo?{mode:\"category\",domain:e.yo}:{mode:\"numeric\",domain:e.Xn,ticks:e.$n}),Zo(e.l,n,s,e.u,t,e.i?.dpr??1,l,e.Be,{value:e.getColumnFormatter(i?.aggName??null,\"tick\"),alt:e.getColumnFormatter(o?.aggName??null,\"tick\"),category:e.getColumnFormatter(r,\"tick\")}),Vc(e),mn(e)&&Lu(e)}function Uc(e){let t=e.b,n=e.l,i=e.v(),o=e.i?.dpr??1,r=e.Be,s=e.h.length>0,l=e.Le===\"numeric\"&&e.I!==null&&e.Ge!==null;if(!ce(n,e.u,o))return;let a=e.le,u=e.te,m=e.ae,f=e.Cn,c=e.Yn===\"category\"&&f!==null&&f.numRows>0,d=e.f.find(x=>x.axis===0),b=e.getColumnFormatter(d?.aggName??null,\"tick\"),g=e.getColumnFormatter(e.h[0],\"tick\");for(let x of t.cells){let y=x.layout,C=y.e,_=le(n,o);_&&(_.strokeStyle=i.di,_.lineWidth=1,_.beginPath(),_.moveTo(C.x,C.y),_.lineTo(C.x,C.y+C.height),_.lineTo(C.x+C.width,C.y+C.height),_.stroke(),r?(!l&&a&&Pe(_,y,a,i),c&&xe(_,y,f,i)):(!l&&a&&xe(_,y,a,i),c&&Pe(_,y,f,i)),x.titleRect&&Ut(n,x.label,x.titleRect,i,o))}let h=l?{min:e.I.min,max:e.I.max,isDate:e.I.isDate,label:e.I.label}:null;r?(h&&t.outerYAxisRect&&En(n,t.outerYAxisRect,h,e.Ge,Mn(t),i,s,o,g),!c&&t.outerXAxisRect&&In(n,t.outerXAxisRect,u,m,wn(t),i,!0,o,b)):(h&&t.outerXAxisRect&&In(n,t.outerXAxisRect,h,e.Ge,wn(t),i,s,o,g),!c&&t.outerYAxisRect&&En(n,t.outerYAxisRect,u,m,Mn(t),i,!0,o,b)),Hc(e,t),mn(e)&&Lu(e)}function Au(e,t,n,i,o){let r=e.l.getContext(\"2d\");if(!r)return;r.save();let s=e.v(),l=t;n.mode===\"floating\"&&(l=ro(r,t,s,n.title,n.opacity));let a=10,u=vn,m=i*u,f=e.F.clampScroll(l.height,m),c=m>l.height,d=Math.max(0,l.width-a-6-(c?10:0));r.beginPath(),r.rect(l.x,l.y,l.width,l.height),r.clip(),r.font=`11px ${s.fontFamily}`,r.textAlign=\"left\",r.textBaseline=\"middle\";let b=l.x,g=Math.floor(f/u),h=l.y+u/2+g*u-f;for(let x=g;x<i&&h-u/2<l.y+l.height;x++){let y=o(x),C=Math.round(y.color[0]*255),_=Math.round(y.color[1]*255),v=Math.round(y.color[2]*255);r.globalAlpha=y.hidden?.3:1,r.fillStyle=`rgb(${C},${_},${v})`,r.fillRect(b,h-a/2,a,a);let A=Mt(r,y.label,d),L=r.measureText(A).width;r.fillStyle=s.cn,r.fillText(A,b+a+6,h),y.hidden&&(r.strokeStyle=s.cn,r.lineWidth=1,r.beginPath(),r.moveTo(b+a+6,h),r.lineTo(b+a+6+L,h),r.stroke()),r.globalAlpha=1,e._n.push({seriesIds:y.seriesIds,rect:{x:b-2,y:h-u/2,width:Math.min(a+6+L+4,Math.max(1,l.width)),height:u}}),h+=u}r.restore(),qr(r,l,f,m,s),e.F.setPainted({mode:n.mode,box:t,content:l,contentHeight:m,sidebarGutter:n.sidebarGutter})}function Hc(e,t){if(e._n=[],!e.l||!e.u)return;let n=e.t,i=e.tt.length,o=se(n,i),r=o===\"floating\";if(i<=1||o===\"none\"||!r&&!t.legendRect){e.F.clearPainted();return}let s=Array.from({length:i},()=>[]),l=Array.from({length:i},()=>[.5,.5,.5]);for(let m of e.f)m.aggIdx>=0&&m.aggIdx<i&&(s[m.aggIdx].push(m.seriesId),l[m.aggIdx]=m.color);let a=e.u,u=r?e.F.floatingBox(n,a.cssWidth,a.cssHeight,st(e.l,e.v(),i,()=>e.tt.slice(0,i),{title:\"Legend\"})):{x:t.legendRect.x+12,y:t.legendRect.y+10,width:Math.max(1,t.legendRect.width-16),height:Math.max(1,t.legendRect.height-20)};Au(e,u,{mode:r?\"floating\":\"sidebar\",legend:e.F,title:\"Legend\",sidebarGutter:r?void 0:t.legendRect.width,opacity:n.legend_opacity},i,m=>({label:e.tt[m],color:l[m],seriesIds:s[m],hidden:s[m].every(f=>e.ne.has(f))}))}function Vc(e){if(e._n=[],!e.l||!e.u)return;let t=e.t,n=e.f,i=se(t,n.length);if(n.length<=1||i===\"none\"){e.F.clearPainted();return}let o=e.u,r=i===\"floating\",s=e.B.join(\" / \")||\"Legend\",l=r?e.F.floatingBox(t,o.cssWidth,o.cssHeight,st(e.l,e.v(),n.length,function*(){for(let a of n)yield a.label},{title:s})):{x:o.e.x+o.e.width+12,y:o.margins.top+10,width:Math.max(1,o.cssWidth-o.e.x-o.e.width-16),height:Math.max(1,o.e.height-10)};Au(e,l,{mode:r?\"floating\":\"sidebar\",legend:e.F,title:s,sidebarGutter:r?void 0:o.margins.right,opacity:t.legend_opacity},n.length,a=>({label:n[a].label,color:n[a].color,seriesIds:[n[a].seriesId],hidden:e.ne.has(n[a].seriesId)}))}function Lu(e){if(!e.l||!e.u)return;let t=mn(e);if(!t)return;let n=Cs(e,t);if(!n)return;let o=(e.f[t.seriesId]?.chartType??\"bar\")===\"bar\"?(t.y0+t.y1)/2:t.y1,r=t.axis===0?e.Be?n.R(o,t.xCenter):n.R(t.xCenter,o):Xo(e,t.xCenter,o,n),s=ys(e,t),l=e.v(),a=e.i?.dpr??1,u=t.axis===0?e.Be?n.R(t.y1,t.xCenter):n.R(t.xCenter,t.y1):Xo(e,t.xCenter,t.y1,n),m=[],f;e.Le===\"numeric\"&&e.V&&e.V[t.catIdx]!=null?f=(e.getColumnFormatter(e.h[0],\"tick\")??fe(e.I?.isDate,e.Ge))(e.V[t.catIdx]):f=_s(e,t.catIdx),f!==\"\"&&m.push({side:e.Be?\"left\":\"bottom\",px:u.px,py:u.py,text:f});let c=t.axis===1?e.Xn:e.te,d=t.axis===1?e.$n:e.ae,b=e.getColumnFormatter(e.f[t.seriesId]?.aggName,\"tick\")??fe(c?.isDate,d);m.push({side:e.Be?\"bottom\":t.axis===1?\"right\":\"left\",px:u.px,py:u.py,text:b(t.y1)}),Ye(e.l,n,l,a,m,e.t.tooltip_opacity),He(e.l,r,s,n,l,a,ie(e.t))}function Xo(e,t,n,i){let o=i??e.u,{x:r,y:s,width:l,height:a}=o.e,u=(t-o.O)/(o.Z-o.O),m=e.oe,f=(n-m.min)/(m.max-m.min);return{px:r+u*l,py:s+(1-f)*a}}function zc(e,t,n){let i=e.wt;if(i&&i.catMin===t&&i.catMax===n&&i.hidden===e.ne)return i;let o=$c(e),r=1/0,s=-1/0,l=!1,a=1/0,u=-1/0,m=!1;if(o.n>0){let c=e.V,d,b;if(c){let v=Yc(c,o.n,t,n);d=v.lo,b=v.hi}else d=Math.max(0,Math.floor(t)),b=Math.min(o.n-1,Math.ceil(n));let g=o.leftMin,h=o.leftMax,x=o.rightMin,y=o.rightMax,C=o.hasLeft,_=o.hasRight;for(let v=d;v<=b;v++)C[v]&&(g[v]<r&&(r=g[v]),h[v]>s&&(s=h[v]),l=!0),_[v]&&(x[v]<a&&(a=x[v]),y[v]>u&&(u=y[v]),m=!0)}let f=i??Xc();return f.catMin=t,f.catMax=n,f.hidden=e.ne,f.leftMin=r,f.leftMax=s,f.hasLeft=l,f.rightMin=a,f.rightMax=u,f.hasRight=m,e.wt=f,f}function Yc(e,t,n,i){if(t===0||n>i)return{lo:0,hi:-1};let o=0,r=t;for(;o<r;){let a=o+r>>>1;e[a]<n?o=a+1:r=a}let s=Math.max(0,o-1);for(o=0,r=t;o<r;){let a=o+r>>>1;e[a]<=i?o=a+1:r=a}let l=Math.min(t-1,o);return{lo:s,hi:l}}function Xc(){return{catMin:0,catMax:0,hidden:new Set,leftMin:0,leftMax:0,hasLeft:!1,rightMin:0,rightMax:0,hasRight:!1}}function $c(e){let t=e.ie,n=e.fr,i=n&&n.leftMin.length>=t;if(n&&i&&e.Ii===e.ne)return n;!n||!i?(n={leftMin:new Float64Array(t),leftMax:new Float64Array(t),rightMin:new Float64Array(t),rightMax:new Float64Array(t),hasLeft:new Uint8Array(t),hasRight:new Uint8Array(t),n:t},e.fr=n):n.n=t;for(let g=0;g<t;g++)n.leftMin[g]=1/0,n.leftMax[g]=-1/0,n.rightMin[g]=1/0,n.rightMax[g]=-1/0,n.hasLeft[g]=0,n.hasRight[g]=0;let o=e.Ae,r=e.ne,s=o.catIdx,l=o.seriesId,a=o.y0,u=o.y1,m=o.axis;for(let g=0;g<o.count;g++){if(r.has(l[g]))continue;let h=s[g];if(h<0||h>=t)continue;let x=a[g],y=u[g],C=x<y?x:y,_=x<y?y:x;m[g]===1?(C<n.rightMin[h]&&(n.rightMin[h]=C),_>n.rightMax[h]&&(n.rightMax[h]=_),n.hasRight[h]=1):(C<n.leftMin[h]&&(n.leftMin[h]=C),_>n.leftMax[h]&&(n.leftMax[h]=_),n.hasLeft[h]=1)}let f=[e.jn,e.Zn],c=e.et,d=e.$t,b=e.f.length;for(let g of f)for(let h of g){if(r.has(h.seriesId))continue;let x=h.axis===1,y=h.seriesId;for(let C=0;C<t;C++){let _=C*b+y;if(!(d[_>>3]>>(_&7)&1))continue;let v=c[_];x?(v<n.rightMin[C]&&(n.rightMin[C]=v),v>n.rightMax[C]&&(n.rightMax[C]=v),n.hasRight[C]=1):(v<n.leftMin[C]&&(n.leftMin[C]=v),v>n.leftMax[C]&&(n.leftMax[C]=v),n.hasLeft[C]=1)}}return e.Ii=r,n}Rn();Be();de();var qn=new Float32Array(0),Kn=new Uint8Array(0);function jc(e){return qn.length>=e||(qn=new Float32Array(Math.max(e,qn.length*2))),qn}function Zc(e){return Kn.length>=e||(Kn=new Uint8Array(Math.max(e,Kn.length*2))),Kn}function qc(e){return e===\"solid\"?1:e===\"transparent\"?.5:0}var Jo=class{constructor(){p(this,\"o\",null);p(this,\"r\",null)}ensureProgram(t){if(this.o)return this.o;let n=at(t.gl),i=j(t,\"bar-line\",Ke,Je,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_start\",\"a_end\",\"a_corner\",\"a_real_start\",\"a_real_end\"]);return this.o={...i,cornerBuffer:n},this.o}invalidateBuffers(t){let n=this.r;if(!n||!t.i){this.r=null;return}let i=t.i.gl;for(let o of n.series)i.deleteBuffer(o.gpuBuffer),i.deleteBuffer(o.gpuRealBuffer);this.r=null}rebuildBuffers(t,n){let i=t.jn;if(i.length===0){this.r=null;return}if(t.ie===0){this.r=null;return}this.ensureProgram(n);let r=n.gl,s=t.et,l=t.$t,a=t.ce,u=t.V,m=t.f.length,f=[];for(let c of i){let d=t.f[c.seriesId],b=d.start,g=d.end;if(b<0||g<b)continue;let h=g-b+1;if(h<2)continue;let x=jc(h*2),y=Zc(h),C=0;for(let A=b;A<=g;A++){let L=u?u[A]-a:A,T=A*m+c.seriesId;x[C*2]=L,x[C*2+1]=s[T],y[C]=l[T>>3]>>(T&7)&1,C++}let _=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,_),r.bufferData(r.ARRAY_BUFFER,x.subarray(0,C*2),r.STATIC_DRAW);let v=r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,v),r.bufferData(r.ARRAY_BUFFER,y.subarray(0,C),r.STATIC_DRAW),f.push({seriesId:c.seriesId,axis:c.axis,color:[c.color[0],c.color[1],c.color[2]],gpuBuffer:_,gpuRealBuffer:v,count:h,interpolateMode:d.interpolateMode})}this.r={series:f}}draw(t,n,i,o,r,s,l){let a=this.r,u=this.o;if(!a||!u||a.series.length===0)return;let m=i.dpr;n.useProgram(u.program),n.uniform2f(u.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(u.u_line_width,t.t.line_width_px*m);let f=Q(i),{setDivisor:c,drawArraysInstanced:d}=f;n.bindBuffer(n.ARRAY_BUFFER,u.cornerBuffer),n.enableVertexAttribArray(u.a_corner),n.vertexAttribPointer(u.a_corner,1,n.FLOAT,!1,0,0),c(u.a_corner,0);let b=2*Float32Array.BYTES_PER_ELEMENT,g=Uint8Array.BYTES_PER_ELEMENT,h=t.ne;for(let x of a.series){if(h.has(x.seriesId)||s!==void 0&&t.f[x.seriesId].splitIdx!==s)continue;let y=t.f[x.seriesId].aggIdx;if(l!==void 0&&(y<l.start||y>l.end))continue;n.uniformMatrix4fv(u.u_projection,!1,x.axis===1?r:o);let C=t.f[x.seriesId].color;n.uniform4f(u.u_color,C[0],C[1],C[2],1),n.uniform1f(u.u_interp_alpha,qc(x.interpolateMode)),n.enableVertexAttribArray(u.a_start),c(u.a_start,1),n.enableVertexAttribArray(u.a_end),c(u.a_end,1),n.enableVertexAttribArray(u.a_real_start),c(u.a_real_start,1),n.enableVertexAttribArray(u.a_real_end),c(u.a_real_end,1),n.bindBuffer(n.ARRAY_BUFFER,x.gpuBuffer),n.vertexAttribPointer(u.a_start,2,n.FLOAT,!1,b,0),n.vertexAttribPointer(u.a_end,2,n.FLOAT,!1,b,b),n.bindBuffer(n.ARRAY_BUFFER,x.gpuRealBuffer),n.vertexAttribPointer(u.a_real_start,1,n.UNSIGNED_BYTE,!1,g,0),n.vertexAttribPointer(u.a_real_end,1,n.UNSIGNED_BYTE,!1,g,g),d(n.TRIANGLE_STRIP,0,4,x.count-1)}c(u.a_start,0),c(u.a_end,0),c(u.a_real_start,0),c(u.a_real_end,0)}destroy(t){let n=t.i?.gl;if(n){this.invalidateBuffers(t);let i=this.o;i&&n.deleteBuffer(i.cornerBuffer)}this.o=null,this.r=null}};de();var qe=new Float32Array(0),Me=new Float32Array(0);function Kc(e){qe.length<e*2&&(qe=new Float32Array(Math.max(e*2,qe.length*2))),Me.length<e*3&&(Me=new Float32Array(Math.max(e*3,Me.length*2)))}var Qo=class{constructor(){p(this,\"o\",null);p(this,\"r\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,i=j(t,\"bar-scatter\",fi,ci,[\"u_projection\",\"u_point_size\"],[\"a_position\",\"a_color\"]);return this.o={...i,posLeftBuffer:n.createBuffer(),posRightBuffer:n.createBuffer(),colorLeftBuffer:n.createBuffer(),colorRightBuffer:n.createBuffer()},this.o}invalidateBuffers(t){this.r=null}rebuildBuffers(t,n){let i=t.Zn;if(i.length===0){this.r=null;return}let o=t.ie,r=t.f.length;if(o===0||r===0){this.r=null;return}let s=this.ensureProgram(n),l=n.gl,a=t.et,u=t.$t,m=t.V,f=t.ce,c=t.ne,d=0,b=0;for(let C of i)if(!c.has(C.seriesId))for(let _=0;_<o;_++){let v=_*r+C.seriesId;u[v>>3]>>(v&7)&1&&(C.axis===1?b++:d++)}let g=d+b;if(g===0){this.r=null;return}Kc(g);let h=[],x=0,y=d;for(let C of i){if(c.has(C.seriesId))continue;let _=C.axis===1?y-d:x,v=C.color[0],A=C.color[1],L=C.color[2];for(let w=0;w<o;w++){let M=w*r+C.seriesId;if(!(u[M>>3]>>(M&7)&1))continue;let I=m?m[w]-f:w,D=a[M];C.axis===1?(qe[y*2]=I,qe[y*2+1]=D,Me[y*3]=v,Me[y*3+1]=A,Me[y*3+2]=L,y++):(qe[x*2]=I,qe[x*2+1]=D,Me[x*3]=v,Me[x*3+1]=A,Me[x*3+2]=L,x++)}let T=C.axis===1?y-d:x;T>_&&h.push({seriesId:C.seriesId,axis:C.axis,first:_,count:T-_})}d>0&&(l.bindBuffer(l.ARRAY_BUFFER,s.posLeftBuffer),l.bufferData(l.ARRAY_BUFFER,qe.subarray(0,d*2),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,s.colorLeftBuffer),l.bufferData(l.ARRAY_BUFFER,Me.subarray(0,d*3),l.STATIC_DRAW)),b>0&&(l.bindBuffer(l.ARRAY_BUFFER,s.posRightBuffer),l.bufferData(l.ARRAY_BUFFER,qe.subarray(d*2,g*2),l.STATIC_DRAW),l.bindBuffer(l.ARRAY_BUFFER,s.colorRightBuffer),l.bufferData(l.ARRAY_BUFFER,Me.subarray(d*3,g*3),l.STATIC_DRAW)),this.r={leftCount:d,rightCount:b,seriesRanges:h}}draw(t,n,i,o,r,s,l){let a=this.r,u=this.o;if(!a||!u||a.leftCount===0&&a.rightCount===0)return;let m=i.dpr;if(n.useProgram(u.program),n.uniform1f(u.u_point_size,t.t.point_size_px*m),s!==void 0||l!==void 0){for(let f of a.seriesRanges){if(s!==void 0&&t.f[f.seriesId].splitIdx!==s)continue;let c=t.f[f.seriesId].aggIdx;l!==void 0&&(c<l.start||c>l.end)||Ts(n,u,f.axis===1?u.posRightBuffer:u.posLeftBuffer,f.axis===1?u.colorRightBuffer:u.colorLeftBuffer,f.count,f.axis===1?r:o,f.first)}return}Ts(n,u,u.posLeftBuffer,u.colorLeftBuffer,a.leftCount,o),Ts(n,u,u.posRightBuffer,u.colorRightBuffer,a.rightCount,r)}destroy(t){let n=t.i?.gl;if(n){let i=this.o;i&&(n.deleteBuffer(i.posLeftBuffer),n.deleteBuffer(i.posRightBuffer),n.deleteBuffer(i.colorLeftBuffer),n.deleteBuffer(i.colorRightBuffer))}this.o=null,this.r=null}};function Ts(e,t,n,i,o,r,s=0){o!==0&&(e.uniformMatrix4fv(t.u_projection,!1,r),e.bindBuffer(e.ARRAY_BUFFER,n),e.enableVertexAttribArray(t.a_position),e.vertexAttribPointer(t.a_position,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(t.a_color),e.vertexAttribPointer(t.a_color,3,e.FLOAT,!1,0,0),e.drawArrays(e.POINTS,s,o))}de();var Jn=new Float32Array(0);function Jc(e){return Jn.length>=e||(Jn=new Float32Array(Math.max(e,Jn.length*2))),Jn}var er=class{constructor(){p(this,\"o\",null);p(this,\"r\",null)}ensureProgram(t){return this.o?this.o:(this.o=j(t,\"bar-area\",ui,mi,[\"u_projection\",\"u_color\",\"u_opacity\"],[\"a_position\"]),this.o)}invalidateBuffers(t){let n=this.r;if(!n||!t.i){this.r=null;return}let i=t.i.gl;for(let o of n.series)i.deleteBuffer(o.gpuBuffer);this.r=null}rebuildBuffers(t,n){let i=t.Pi;if(i.length===0){this.r=null;return}let o=t.ie,r=t.f.length;if(o===0||r===0){this.r=null;return}this.ensureProgram(n);let s=n.gl,l=t.et,a=t.$t,u=t.V,m=t.ce,f=t._o,c=t.Ae,d=[];for(let b of i){let g=t.f[b.seriesId],h=Qc(b,o,r,l,a,f,c.y0,c.y1,u,m,g.start,g.end,g.interpolateMode);if(h.totalVertices===0)continue;let x=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,x),s.bufferData(s.ARRAY_BUFFER,h.scratch.subarray(0,h.totalVertices*2),s.STATIC_DRAW),d.push({seriesId:b.seriesId,axis:b.axis,color:[b.color[0],b.color[1],b.color[2]],gpuBuffer:x,strips:h.descriptors})}this.r={series:d}}draw(t,n,i,o,r,s,l,a){let u=this.r,m=this.o;if(!u||!m||u.series.length===0)return;n.useProgram(m.program),n.uniform1f(m.u_opacity,s);let f=t.ne;for(let c of u.series){if(f.has(c.seriesId)||l!==void 0&&t.f[c.seriesId].splitIdx!==l)continue;let d=t.f[c.seriesId].aggIdx;if(a!==void 0&&(d<a.start||d>a.end))continue;n.uniformMatrix4fv(m.u_projection,!1,c.axis===1?r:o);let b=t.f[c.seriesId].color;n.uniform3f(m.u_color,b[0],b[1],b[2]),n.bindBuffer(n.ARRAY_BUFFER,c.gpuBuffer),n.enableVertexAttribArray(m.a_position),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,0);for(let g of c.strips)n.bindBuffer(n.ARRAY_BUFFER,c.gpuBuffer),n.vertexAttribPointer(m.a_position,2,n.FLOAT,!1,0,g.offsetBytes),n.drawArrays(n.TRIANGLE_STRIP,0,g.vertexCount)}}destroy(t){this.invalidateBuffers(t),this.o=null}};function Qc(e,t,n,i,o,r,s,l,a,u,m,f,c){let d=Jc(t*4),b=[],g=e.seriesId*1e9,h=c!==\"skip\",x=0,y=0;for(let C=0;C<t;C++){let _=0,v=0,A=!1;if(e.stack){let L=r?.get(g+C);L!==void 0&&(_=s[L],v=l[L],A=!0)}else{let L=C*n+e.seriesId;h?C>=m&&C<=f&&(v=i[L],A=!0):o[L>>3]>>(L&7)&1&&(v=i[L],A=!0)}if(A){let L=a?a[C]-u:C;d[x++]=L,d[x++]=_,d[x++]=L,d[x++]=v}else if(x>y){let L=(x-y)/2;L>=4&&b.push({offsetBytes:y*4,vertexCount:L}),y=x}}if(x>y){let C=(x-y)/2;C>=4&&b.push({offsetBytes:y*4,vertexCount:C})}return{descriptors:b,totalVertices:x/2,scratch:d}}Be();de();function Qn(e,t){return e&&(t.min=Math.min(e.min,t.min),t.max=Math.max(e.max,t.max)),{min:t.min,max:t.max}}var ct=class extends un{constructor(n=\"vertical\"){super();p(this,\"Be\");p(this,\"E\",null);p(this,\"tt\",[]);p(this,\"ge\",[]);p(this,\"f\",[]);p(this,\"jt\",!1);p(this,\"b\",null);p(this,\"Ei\",null);p(this,\"Xt\",[]);p(this,\"Vn\",null);p(this,\"Hn\",null);p(this,\"Ae\",Ho());p(this,\"Co\",[]);p(this,\"jn\",[]);p(this,\"Zn\",[]);p(this,\"Pi\",[]);p(this,\"xo\",\"\");p(this,\"ur\",\"\");p(this,\"Yn\",\"numeric\");p(this,\"mr\",null);p(this,\"Cn\",null);p(this,\"yo\",null);p(this,\"_o\",null);p(this,\"Je\",null);p(this,\"Bi\",null);p(this,\"Gi\",null);p(this,\"vo\",null);p(this,\"Ao\",null);p(this,\"ho\",{min:0,max:1});p(this,\"oe\",null);p(this,\"yn\",!1);p(this,\"qn\",null);p(this,\"Kn\",null);p(this,\"Wi\",null);p(this,\"Le\",\"category\");p(this,\"I\",null);p(this,\"ce\",0);p(this,\"Ge\",null);p(this,\"V\",null);p(this,\"ne\",new Set);p(this,\"Ee\",-1);p(this,\"go\",-1);p(this,\"Pe\",null);p(this,\"et\",new Float32Array(0));p(this,\"$t\",new Uint8Array(0));p(this,\"Y\",{lines:new Jo,scatter:new Qo,areas:new er});p(this,\"Xn\",null);p(this,\"$n\",null);p(this,\"Un\",0);p(this,\"zn\",new Int32Array(0));p(this,\"_n\",[]);p(this,\"ar\",!1);p(this,\"wt\",null);p(this,\"fr\",null);p(this,\"Ii\",null);this.Be=n===\"horizontal\"}getZoomConfig(){return{lockAxis:this.Be?\"x\":\"y\"}}repaintChrome(){Ko(this)}tooltipCallbacks(){return{onHover:(n,i)=>xs(this,n,i),onLeave:()=>{(this.Ee!==-1||this.Pe)&&(this.Ee=-1,this.Pe=null,this.i&&this.requestRender(this.i))},onClickPre:(n,i)=>pu(this,n,i),onPin:(n,i)=>{if(xs(this,n,i),this.Ee>=0){let o=this.Ee;bu(this,o);let r=Zn(this.Ae,o,this.ge.length,this.et,this.f.length);this.cr(r)}else if(this.Pe){let o=this.Pe;gu(this,o),this.cr(o)}},onUnpin:()=>{this.emitUnselect()}}}async cr(n){if(!this.tt[n.aggIdx])return;let i=this.Le===\"numeric\"&&this.V?[this.V[n.catIdx]??null]:this.Ie.map(s=>s.labels[n.catIdx]??null),o=this.ge[n.splitIdx]??\"\",r=this.B.length>0&&o!==\"\"?o.split(\"|\"):[];await this.emitClickAndSelect({rowIdx:n.catIdx+this.bt,columnName:this.tt[n.aggIdx],groupByValues:i,splitByValues:r})}async uploadAndRender(n,i,o,r){this.i=n;let s=n.gl;if(o!==0)return;if(!this.o){let u=j(n,\"bar\",ii,oi,[\"u_proj_left\",\"u_proj_right\",\"u_hover_series\",\"u_horizontal\"],[\"a_corner\",\"a_x_center\",\"a_half_width\",\"a_y0\",\"a_y1\",\"a_color\",\"a_series_id\",\"a_axis\"]);this.o=u.program,this.E=u,this.H=fo(s)}let l=this.B.length>0&&this.W.facet_mode===\"grid\",a=fu({columns:i,numRows:r,columnSlots:this.L,groupBy:this.h,splitBy:this.B,groupByTypes:this.vt,columnsConfig:this.Dn,defaultChartType:this.xi,autoAltYAxis:this.t.auto_alt_y_axis,bandInnerFrac:this.t.band_inner_frac,barInnerPad:this.t.bar_inner_pad,includeZero:this.t.include_zero,facetSplits:l,scratchBars:this.Ae,scratchPosStack:this.vo,scratchNegStack:this.Ao});if(this.t.domain_mode===\"expand\"){let u=td(a);this.Wi!==u&&(this.qn=null,this.Kn=null,this.Wi=u),this.qn=Qn(this.qn,a.leftDomain),a.rightDomain&&(this.Kn=Qn(this.Kn,a.rightDomain))}else this.qn=null,this.Kn=null,this.Wi=null;this.tt=a.aggregates,this.ge=a.splitPrefixes,this.jt=l&&a.splitPrefixes.length>1,this.Ie=a.rowPaths,this.ie=a.numCategories,this.bt=a.rowOffset,this.Le=a.axisMode.mode,this.I=a.numericCategoryDomain,this.V=a.categoryPositions,this.ce=a.numericCategoryDomain?.min??0,this.f=a.series,this.Ae=a.bars,this.vo=a.posStack,this.Ao=a.negStack,this.et=a.samples,this.Co.length=0,this.jn.length=0,this.Zn.length=0,this.Pi.length=0;for(let u of a.series)switch(u.chartType){case\"bar\":this.Co.push(u);break;case\"line\":this.jn.push(u);break;case\"scatter\":this.Zn.push(u);break;case\"area\":this.Pi.push(u);break}this.xo=Tu(a.series,0),this.ur=Tu(a.series,1),this.Xt.length=0;{let u=Math.max(1,a.splitPrefixes.length);for(let m=0;m<a.aggregates.length;m++){let f=a.series[m*u].chartType,c=this.Xt[this.Xt.length-1];c&&c.chartType===f?c.aggEnd=m:this.Xt.push({chartType:f,aggStart:m,aggEnd:m})}}this._o=ed(this.Ae),this.wt=null,this.ar=!1,this.Bi=null,this.Gi=null,this.Ii=null,this.Je=null,this.Ee=-1,this.Pe=null,this.$t=a.sampleValid,this.ho=a.leftDomain,this.oe=a.rightDomain,this.yn=a.hasRightAxis,this.Yn=a.leftValueAxisMode,this.mr=a.rightValueAxisMode,this.Cn=a.leftValueCategoryDomain,this.yo=a.rightValueCategoryDomain,Ls(this),zo(this,n),_u(this),Yo(this,n),await this.requestRender(n)}kt(n){this.o&&(this.i=n,Cu(this,n))}resetExpandedDomain(){this.qn=null,this.Kn=null,this.Wi=null}destroyInternal(){if(this.i){let n=this.i.gl;this.H&&n.deleteBuffer(this.H),id(this)}this.o=null,this.E=null,this.H=null,this.jt=!1,this.b=null,this.Ei=null,this.Hn=null,this.Vn=null,this.Xt.length=0,this.Ae=Ho(),this.f=[],this.Co=[],this.jn=[],this.Zn=[],this.Pi=[],this._o=null,this.Bi=null,this.Gi=null,this.Je=null,this.vo=null,this.Ao=null,this.Ie=[],this.ie=0,this.ne.clear(),this.Ee=-1,this.Pe=null}};function ed(e){let t=new Map;for(let n=0;n<e.count;n++)e.chartType[n]===1&&t.set(e.seriesId[n]*1e9+e.catIdx[n],n);return t}function Tu(e,t){let n=new Set,i=[];for(let o of e)o.axis===t&&(n.has(o.aggName)||(n.add(o.aggName),i.push(o.aggName)));return i.join(\", \")}function td(e){let t=Math.max(1,e.splitPrefixes.length),n=[];for(let i=0;i<e.aggregates.length;i++)n.push(`${e.aggregates[i]}:${e.series[i*t].axis}`);return n.join(\"\\0\")}function Ls(e){let t=e.v(),n=t.Ne,i=t.N,o=e.Dn,r=e.jt?Math.max(1,e.tt.length):e.f.length,s=e.Gi;if(e.Bi&&s&&s.Ne===n&&s.N===i&&s.seriesLength===r&&s.columnsConfig===o)return!1;let l=nd(n,i,r);e.Bi=l,e.Gi={Ne:n,N:i,seriesLength:r,columnsConfig:o};for(let a=0;a<e.f.length;a++){let u=e.f[a],m=e.jt?l[u.aggIdx]:l[a];u.color=su(u,e.jt,o)??m}return!0}function nd(e,t,n){return he(e,t,n)}function id(e){e.Y.lines.destroy(e),e.Y.scatter.destroy(e),e.Y.areas.destroy(e)}var tr=class extends ct{constructor(){super(\"horizontal\")}};Ln();ot();kn();function ws(e){let{columns:t,numRows:n,groupBy:i,splitBy:o,groupByTypes:r}=e,s=sn(i,r),l={xLevels:[],yColumnNames:[],yLevels:[],numX:0,numY:0,rowOffset:0,cells:[],cells2D:[],colorMin:0,colorMax:1,xAxisMode:s,yAxisMode:{mode:\"category\"},xPositions:null,yPositions:null,xNumericDomain:null,yNumericDomain:null},a=i.map(w=>r[w]??\"string\"),{rowPaths:u,numCategories:m,rowOffset:f}=ln(t,n,i.length,a,s),c=null,d=null;if(s.mode===\"numeric\"&&m>0){let w=t.get(\"__ROW_PATH_0__\"),M=Dt(w?.values,m,f,i[0]??\"\",s.numericType===\"date\"||s.numericType===\"datetime\");M&&(c=M.categoryPositions,d=M.numericCategoryDomain)}let b=[];for(let w of t.keys())w.startsWith(\"__\")||!t.get(w)?.values||b.push(w);let g=b.length;if(m===0||g===0)return{...l,xLevels:u,rowOffset:f};let h=sd(b),x=od(o,r),y={mode:\"category\"},C=null,_=null;if(x.mode===\"numeric\"){let w=rd(b,x.numericType);if(w){let M=Dt(w,g,0,o[0]??\"\",x.numericType===\"date\"||x.numericType===\"datetime\");M&&(y=x,C=M.categoryPositions,_=M.numericCategoryDomain)}}let v=[],A=new Array(m*g).fill(null),L=1/0,T=-1/0;for(let w=0;w<g;w++){let M=t.get(b[w]),I=M.values,D=M.valid;for(let S=0;S<m;S++){let E=S+f;if(D&&!(D[E>>3]>>(E&7)&1))continue;let k=I[E];if(!isFinite(k))continue;let W={xIdx:S,yIdx:w,value:k};v.push(W),A[w*m+S]=W,k<L&&(L=k),k>T&&(T=k)}}return!isFinite(L)||!isFinite(T)?(L=0,T=1):L===T&&(T=L+1),{xLevels:u,yColumnNames:b,yLevels:h,numX:m,numY:g,rowOffset:f,cells:v,cells2D:A,colorMin:L,colorMax:T,xAxisMode:s,yAxisMode:y,xPositions:c,yPositions:C,xNumericDomain:d,yNumericDomain:_}}function od(e,t){if(e.length!==1)return{mode:\"category\"};let n=t[e[0]];return n===\"date\"||n===\"datetime\"||n===\"integer\"||n===\"float\"?{mode:\"numeric\",numericType:n}:{mode:\"category\"}}function rd(e,t){let n=new Float64Array(e.length);for(let i=0;i<e.length;i++){let o=e[i],r=o.indexOf(\"|\"),s=r===-1?o:o.slice(0,r),l;if(t===\"date\"||t===\"datetime\"?(l=Date.parse(s),isFinite(l)||(l=Date.parse(s.replace(\" \",\"T\")))):l=Number(s),!isFinite(l))return null;n[i]=l}return n}function wu(e,t){return t.map(n=>{let i=new Map;for(let[o,r]of e){if(o.startsWith(\"__ROW_PATH_\")||o===\"__GROUPING_ID__\"){i.set(o,r);continue}let s=o.lastIndexOf(\"|\");(s===-1?o:o.slice(s+1))===n&&i.set(o,r)}return{label:n,columns:i}})}function sd(e){if(e.length===0)return[];let t=0,n=e.map(o=>o.split(\"|\"));for(let o of n)o.length>t&&(t=o.length);if(t===0)return[];let i=[];for(let o=0;o<t;o++){let r=[],s=new Map,l=new Int32Array(e.length),a=new Array(e.length),u=0;for(let c=0;c<e.length;c++){let d=n[c][o]??\"\",b=s.get(d);b===void 0&&(b=r.length,r.push(d),s.set(d,b)),l[c]=b,a[c]=d,d.length>u&&(u=d.length)}let f=o===t-1?[]:no(l,r,0,e.length);i.push({labels:a,runs:f,maxLabelChars:u})}return i}ot();ji();Fn();Be();de();Tt();Ht();Jt();kn();to();function Rs(e,t){return t?.skipLeafLevel&&e.length>0?e.slice(0,-1):e}var ld=80,ad=20,Ms=5,Fs=11;function fn(e,t){return e.R(0,t).py}function Mu(e,t){let n=Rs(e.levels,t),i=n.length,o=[];for(let r=0;r<i;r++){let s=n[r].maxLabelChars;if(r===i-1){let l=Math.max(ld,s*6.5+16);o.push({size:l})}else{let l=Math.max(ad,s*6.5+16);o.push({size:l})}}return o}function Ru(e,t){let n=Rs(e.levels,t);if(e.numRows===0||n.length===0)return 55;let i=Mu(e,t),o=0;for(let r of i)o+=r.size;return o}function ud(e,t){return e.labels[t]??\"\"}function Ss(e,t,n,i,o){let r=Rs(n.levels,o);if(n.numRows===0||r.length===0)return;let{Ct:s,Fe:l,fontFamily:a}=i,{e:u}=t;e.strokeStyle=s,e.fillStyle=s,e.lineWidth=1,e.font=`${Fs}px ${a}`;let m=Mu(n,o),f=Math.max(0,Math.ceil(t.q)),c=Math.min(n.numRows-1,Math.floor(t.ee));if(c<f)return;let d=r.length,b=u.x;for(let h=d-1;h>=0;h--){let x=r[h],y=m[h],C=b,_=b-y.size;b=_,h===d-1?md(e,t,x,f,c,C,_,a,s):fd(e,t,x,f,c,_,C,a,s)}let g=n.levelLabels.filter(h=>!!h).join(\" / \");g&&(e.fillStyle=l,e.font=`13px ${a}`,e.save(),e.translate(14,u.y+u.height/2),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"top\",e.fillText(g,0,0),e.restore())}function md(e,t,n,i,o,r,s,l,a){let u=t.e;e.strokeStyle=a,e.fillStyle=a,e.beginPath();for(let f=i;f<=o;f++){let c=fn(t,f);c<u.y-1||c>u.y+u.height+1||(e.moveTo(r,c),e.lineTo(r-Ms,c))}e.stroke(),e.font=`${Fs}px ${l}`,e.textAlign=\"right\",e.textBaseline=\"middle\";let m=r-Ms-4-s-4;for(let f=i;f<=o;f++){let c=fn(t,f);if(c<u.y-1||c>u.y+u.height+1)continue;let d=ud(n,f);if(!d)continue;let b=wt(e,d,m);b&&e.fillText(b,r-Ms-4,c)}}function fd(e,t,n,i,o,r,s,l,a){let u=t.e,m=Wn(n.runs,i,o);if(m.length===0)return;e.strokeStyle=a,e.fillStyle=a;let f=s-3;e.beginPath();for(let c of m){let d=fn(t,c.endIdx+.5),b=fn(t,c.startIdx-.5),g=Math.min(d,b),h=Math.max(d,b),x=Math.max(u.y,g),y=Math.min(u.y+u.height,h);y<=x||(e.moveTo(f,x),e.lineTo(f,y),e.moveTo(f,x),e.lineTo(f+3,x),e.moveTo(f,y),e.lineTo(f+3,y))}e.stroke(),e.font=`${Fs}px ${l}`;for(let c of m){let d=fn(t,c.endIdx+.5),b=fn(t,c.startIdx-.5),g=Math.min(d,b),h=Math.max(d,b),x=Math.max(u.y,g),y=Math.min(u.y+u.height,h);if(y<=x)continue;let C=(x+y)/2,_=r+(s-r-3)/2,v=c.label;if(!v)continue;let A=y-x-4,L=wt(e,v,Math.max(0,A));L&&(e.save(),e.translate(_,C),e.rotate(-Math.PI/2),e.textAlign=\"center\",e.textBaseline=\"middle\",e.fillText(L,0,0),e.restore())}}Ce();Nn();Ve();ge();Vt();Nt();Dn();Ce();be();function Is(e,t,n){if(e.dr=t,e.pr=n,e.d.length>0){for(let o=0;o<e.d.length;o++){let r=e.d[o],s=r.layout.e;if(t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height)continue;let l=Su(r.layout,r.pipeline.numX,r.pipeline.numY,r.pipeline.cells2D,r.pipeline.xPositions,r.pipeline.yPositions,r.pipeline.xNumericDomain?.bandWidth??1,r.pipeline.yNumericDomain?.bandWidth??1,t,n);Ds(e,l,o);return}Ds(e,null,-1);return}if(!e.u)return;let i=Su(e.u,e.Mt,e.Rt,e.ki,e.Ft,e.vn,e.nt?.bandWidth??1,e.gt?.bandWidth??1,t,n);Ds(e,i,-1)}function Fu(e,t,n){if(e.length===0)return-1;let i=0,o=e.length-1;for(;i<o;){let s=i+o>>1;e[s]<t?i=s+1:o=s}let r=i;return r>0&&Math.abs(e[r-1]-t)<Math.abs(e[r]-t)&&(r-=1),Math.abs(e[r]-t)>n*.5?-1:r}function Su(e,t,n,i,o,r,s,l,a,u){let m=e.e;if(a<m.x||a>m.x+m.width||u<m.y||u>m.y+m.height)return null;let f=e.O,c=e.Z,d=e.q,b=e.ee,g=f+(a-m.x)/m.width*(c-f),h=b-(u-m.y)/m.height*(b-d),x=o?Fu(o,g,s):Math.round(g),y=r?Fu(r,h,l):Math.round(h);return x<0||x>=t||y<0||y>=n?null:i[y*t+x]??null}function Ds(e,t,n){let i=e.Ye;(i?.xIdx??-1)===(t?.xIdx??-1)&&(i?.yIdx??-1)===(t?.yIdx??-1)&&e.Jn===n||(e.Ye=t,e.Jn=n,e.i&&e.Lo&&e.Lo())}function Du(e,t){let n=[];for(let i of e){let o=i.labels[t];o!=null&&o!==\"\"&&n.push(o)}return n.join(\" / \")}function Es(e){if(!e.l||!e.Ye)return;let t,n,i,o,r,s,l=null;if(e.Jn>=0){let C=e.d[e.Jn];if(!C)return;t=C.layout,n=C.pipeline.xLevels,i=C.pipeline.yLevels,o=C.pipeline.xPositions,r=C.pipeline.yPositions,s=C.pipeline.xNumericDomain,l=C.label}else{if(!e.u)return;t=e.u,n=e.Zt,i=e.qt,o=e.Ft,r=e.vn,s=e.nt}let a=e.Ye,u={px:e.dr,py:e.pr},m=[];l&&m.push([l]);let f=e.St.mode===\"numeric\"&&o?e.getColumnFormatter(e.h[0],\"value\")(o[a.xIdx]):Du(n,a.xIdx),c=Du(i,a.yIdx);f&&m.push([f]),c&&m.push([c]);let d=e.getColumnFormatter(e.L[0],\"value\");m.push([\"Value\",d(a.value)]);let b=e.v(),g=e.i?.dpr??1,h=t.R(o?o[a.xIdx]:a.xIdx,r?r[a.yIdx]:a.yIdx),x=e.St.mode===\"numeric\"&&o?(e.getColumnFormatter(e.h[0],\"tick\")??fe(s?.isDate,K(t.O,t.Z,6)))(o[a.xIdx]):f,y=[];x&&y.push({side:\"bottom\",px:h.px,py:h.py,text:x}),c&&y.push({side:\"left\",px:h.px,py:h.py,text:c}),Ye(e.l,t,b,g,y,e.t.tooltip_opacity),He(e.l,u,m,t,b,g,ie(e.t))}var Ps={skipLeafLevel:!0};function Iu(e,t){let n=t.gl,i=t.dpr,o=n.canvas.width/i,r=n.canvas.height/i;if(o<=0||r<=0)return;if(e.d.length>0){dd(e,t,o,r);return}if(e.Mt===0||e.Rt===0)return;let s=e.v(),l={levels:e.Zt,numRows:e.Mt,levelLabels:e.h.slice()},a={levels:e.qt,numRows:e.Rt,levelLabels:[]},u=e.St.mode===\"numeric\",m=e.Qn.mode===\"numeric\",f=nt(e.t,!0,80,0),c=m?55:Ru(a,Ps),d=u?24:Xe(l,Math.max(1,o-c-30-f)),b=new oe(o,r,{hasXLabel:e.h.length>0,hasYLabel:!1,hasLegend:!0,bottomExtra:d,leftExtra:c,rightExtra:f});e.u=b,e._&&e._.updateLayout(b);let g=u?e.nt.min:-.5,h=u?e.nt.max:e.Mt-.5,x=m?e.gt.min:-.5,y=m?e.gt.max:e.Rt-.5;e._&&e._.setBaseDomain(g,h,x,y);let C=e._?e._.getVisibleDomain():{xMin:g,xMax:h,yMin:x,yMax:y},_=b.buildProjectionMatrix(C.xMin,C.xMax,C.yMin,C.yMax,void 0,void 0,0,e.S,e.D),v=b.e,A=v.width/(C.xMax-C.xMin),L=v.height/(C.yMax-C.yMin),T=s.$o*.5,w=u?e.nt.bandWidth:1,M=m?e.gt.bandWidth:1,I=Math.min(w*.5,A>0?T/A:0),D=Math.min(M*.5,L>0?T/L:0);if(e.Q){let S=ce(e.Q,b,t.dpr)}Eu(e,t),Pu(e,t),e.se=Sn(t,e.se,s.N),rt(n,b,t.dpr,()=>{n.useProgram(e.o);let S=e.E;n.uniformMatrix4fv(S.u_projection,!1,_),n.uniform2f(S.u_cell_inset,I,D),n.uniform2f(S.u_cell_size,w,M),ze(t,e.se.texture,S.u_gradient_lut,0),Bu(e,n,t,0,e.br)}),e._e(()=>nr(e))}function Eu(e,t){if(e.o)return;let n=t.gl,i=j(t,\"heatmap\",bi,gi,[\"u_projection\",\"u_cell_inset\",\"u_cell_size\",\"u_gradient_lut\"],[\"a_corner\",\"a_cell\",\"a_color_t\"]);e.o=i.program,e.E=i;let o=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,1,1]),n.STATIC_DRAW),e.H=o}function Pu(e,t){let n=e.ot.length;if(e.br=n,n===0)return;let i=new Float32Array(n*2),o=new Float32Array(n);if(e.d.length>0){let r=0;for(let s of e.d){let l=s.pipeline.xPositions,a=s.pipeline.yPositions,u=s.xOrigin,m=s.yOrigin;for(let f of s.pipeline.cells)i[r*2]=l?l[f.xIdx]-u:f.xIdx,i[r*2+1]=a?a[f.yIdx]-m:f.yIdx,o[r]=Ct(f.value,e.p,e.c),r++}}else{let r=e.Ft,s=e.vn,l=e.S,a=e.D;for(let u=0;u<n;u++){let m=e.ot[u];i[u*2]=r?r[m.xIdx]-l:m.xIdx,i[u*2+1]=s?s[m.yIdx]-a:m.yIdx,o[u]=Ct(m.value,e.p,e.c)}}t.A.ensureCapacity(n),t.A.upload(\"heatmap_cell\",i,0,2),t.A.upload(\"heatmap_t\",o,0,1)}function Bu(e,t,n,i,o){if(o===0)return;let r=e.E,s=Q(n),{setDivisor:l}=s,a=Float32Array.BYTES_PER_ELEMENT;t.bindBuffer(t.ARRAY_BUFFER,e.H),t.enableVertexAttribArray(r.a_corner),t.vertexAttribPointer(r.a_corner,2,t.FLOAT,!1,0,0),l(r.a_corner,0);let u=n.A.peek(\"heatmap_cell\"),m=n.A.peek(\"heatmap_t\");!u||!m||(t.bindBuffer(t.ARRAY_BUFFER,u.buffer),t.enableVertexAttribArray(r.a_cell),t.vertexAttribPointer(r.a_cell,2,t.FLOAT,!1,0,i*2*a),l(r.a_cell,1),t.bindBuffer(t.ARRAY_BUFFER,m.buffer),t.enableVertexAttribArray(r.a_color_t),t.vertexAttribPointer(r.a_color_t,1,t.FLOAT,!1,0,i*a),l(r.a_color_t,1),s.drawArraysInstanced(t.TRIANGLE_STRIP,0,4,o),l(r.a_cell,0),l(r.a_color_t,0))}function nr(e){cd(e),e.presentOverlay()}function cd(e){if(!e.l)return;if(e.d.length>0){pd(e);return}if(!e.u)return;let t=e.u,n=e.v(),i=e.i?.dpr??1,o=ce(e.l,t,i);if(!o)return;o.strokeStyle=n.Rn,o.lineWidth=1,o.beginPath(),o.moveTo(t.e.x,t.e.y),o.lineTo(t.e.x,t.e.y+t.e.height),o.lineTo(t.e.x+t.e.width,t.e.y+t.e.height),o.stroke();let r={levels:e.Zt,numRows:e.Mt,levelLabels:e.h.slice()},s={levels:e.qt,numRows:e.Rt,levelLabels:[]},l=e.h[0],a=e.h[1]??e.B[0];if(e.St.mode===\"numeric\"&&e.nt){let m=K(t.O,t.Z,6);$o(o,t,e.nt,m,n,e.getColumnFormatter(l,\"tick\"))}else xe(o,t,r,n);if(e.Qn.mode===\"numeric\"&&e.gt){let m=K(t.q,t.ee,6);jo(o,t,e.gt,m,n,e.getColumnFormatter(a,\"tick\"))}else Ss(o,t,s,n,Ps);let u=se(e.t,0);if(u===\"none\")e.F.clearPainted();else{let m={min:e.p,max:e.c,label:e.Kt},f=e.getColumnFormatter(e.L[0],\"value\"),c={mode:u===\"floating\"?\"floating\":\"sidebar\",legend:e.F,title:e.Kt,opacity:e.t.legend_opacity};u===\"floating\"?$e(e.l,e.F.floatingBox(e.t,t.cssWidth,t.cssHeight,Rt(e.l,n,m,f,e.Kt)),m,n.N,n,f,c):Qt(e.l,t,m,n.N,n,f,c)}e.Ye&&Es(e)}function dd(e,t,n,i){let o=t.gl,r=e.v(),{effectiveSharedX:s,effectiveSharedY:l}=e.computeEffectiveFacetFlags(),a=Ie(e.d.map(m=>m.label),{cssWidth:n,cssHeight:i,xAxis:s?\"outer\":\"cell\",yAxis:l?\"outer\":\"cell\",hasLegend:se(e.t,0)===\"sidebar\",legendWidth:we(e.t,96),hasXLabel:e.h.length>0,hasYLabel:!1,gap:8});e.b=a;for(let m=0;m<e.d.length;m++){let f=a.cells[m];f&&(e.d[m].layout=f.layout)}e.syncFacetZoomLayouts(a.cells),Eu(e,t),Pu(e,t),e.se=Sn(t,e.se,r.N),o.useProgram(e.o);let u=e.E;ze(t,e.se.texture,u.u_gradient_lut,0),At(o);for(let m=0;m<e.d.length;m++){let f=e.d[m];if(f.instanceCount===0)continue;let{numX:c,numY:d}=f.pipeline;if(c===0||d===0)continue;let b=f.layout,g=f.pipeline.xAxisMode.mode===\"numeric\",h=f.pipeline.yAxisMode.mode===\"numeric\",x=g?f.pipeline.xNumericDomain.min:-.5,y=g?f.pipeline.xNumericDomain.max:c-.5,C=h?f.pipeline.yNumericDomain.min:-.5,_=h?f.pipeline.yNumericDomain.max:d-.5,v=e.getZoomControllerForFacet(m);v&&v.setBaseDomain(x,y,C,_);let A=v?v.getVisibleDomain():{xMin:x,xMax:y,yMin:C,yMax:_},L=b.buildProjectionMatrix(A.xMin,A.xMax,A.yMin,A.yMax,void 0,void 0,0,f.xOrigin,f.yOrigin),T=b.e,w=T.width/(A.xMax-A.xMin),M=T.height/(A.yMax-A.yMin),I=r.$o*.5,D=g?f.pipeline.xNumericDomain.bandWidth:1,S=h?f.pipeline.yNumericDomain.bandWidth:1,E=Math.min(D*.5,w>0?I/w:0),k=Math.min(S*.5,M>0?I/M:0);Lt(o,b,t.dpr,()=>{o.uniformMatrix4fv(u.u_projection,!1,L),o.uniform2f(u.u_cell_inset,E,k),o.uniform2f(u.u_cell_size,D,S),Bu(e,o,t,f.instanceStart,f.instanceCount)})}e._e(()=>nr(e))}function pd(e){if(!e.l||!e.b)return;let t=e.v(),n=e.i?.dpr??1,i=ce(e.l,e.d[0].layout,n);if(!i)return;let o=e.bi,r=e.gi,s=e.b;for(let f=0;f<e.d.length;f++){let c=e.d[f],d=s.cells[f],b=c.layout,g=b.e;i.strokeStyle=t.Rn,i.lineWidth=1,i.beginPath(),i.moveTo(g.x,g.y),i.lineTo(g.x,g.y+g.height),i.lineTo(g.x+g.width,g.y+g.height),i.stroke();let h={levels:c.pipeline.xLevels,numRows:c.pipeline.numX,levelLabels:e.h.slice()},x={levels:c.pipeline.yLevels,numRows:c.pipeline.numY,levelLabels:[]},y=e.h[0],C=e.h[1]??e.B[0];if(!o||d.isBottomEdge)if(c.pipeline.xAxisMode.mode===\"numeric\"&&c.pipeline.xNumericDomain){let _=K(b.O,b.Z,6);$o(i,b,c.pipeline.xNumericDomain,_,t,e.getColumnFormatter(y,\"tick\"))}else xe(i,b,h,t);if(!r||d.isLeftEdge)if(c.pipeline.yAxisMode.mode===\"numeric\"&&c.pipeline.yNumericDomain){let _=K(b.q,b.ee,6);jo(i,b,c.pipeline.yNumericDomain,_,t,e.getColumnFormatter(C,\"tick\"))}else Ss(i,b,x,t,Ps)}for(let f=0;f<s.cells.length;f++){let c=s.cells[f],d=e.d[f];!d||!c.titleRect||Ut(e.l,d.label,c.titleRect,t,n)}let l=se(e.t,0),a=l===\"floating\",u=e.d[0].layout,m=a?e.F.floatingBox(e.t,u.cssWidth,u.cssHeight,Rt(e.l,t,{min:e.p,max:e.c},e.getColumnFormatter(e.L[0],\"value\"),e.Kt)):s.legendRect;l!==\"none\"&&m?$e(e.l,a?m:{x:m.x,y:m.y+20,width:m.width,height:Math.max(1,m.height-20)},{min:e.p,max:e.c,label:\"\"},t.N,t,e.getColumnFormatter(e.L[0],\"value\"),{mode:a?\"floating\":\"sidebar\",legend:e.F,title:e.Kt,sidebarGutter:a?void 0:s.legendRect?.width,opacity:e.t.legend_opacity}):e.F.clearPainted(),e.Ye&&Es(e)}var ir=class extends De{constructor(){super(...arguments);p(this,\"o\",null);p(this,\"E\",null);p(this,\"H\",null);p(this,\"se\",null);p(this,\"Zt\",[]);p(this,\"qt\",[]);p(this,\"To\",[]);p(this,\"Mt\",0);p(this,\"Rt\",0);p(this,\"bt\",0);p(this,\"St\",{mode:\"category\"});p(this,\"Qn\",{mode:\"category\"});p(this,\"Ft\",null);p(this,\"vn\",null);p(this,\"nt\",null);p(this,\"gt\",null);p(this,\"S\",0);p(this,\"D\",0);p(this,\"ot\",[]);p(this,\"ki\",[]);p(this,\"br\",0);p(this,\"p\",0);p(this,\"c\",1);p(this,\"Kt\",\"\");p(this,\"Ye\",null);p(this,\"u\",null);p(this,\"dr\",0);p(this,\"pr\",0);p(this,\"d\",[]);p(this,\"b\",null);p(this,\"Jn\",-1);p(this,\"Lo\",()=>nr(this))}colorScaleColumn(){return this.L[0]||null}tooltipCallbacks(){return{onHover:(n,i)=>Is(this,n,i),onLeave:()=>{this.Ye&&(this.Ye=null,this.Lo())},onPin:(n,i)=>{Is(this,n,i),this.Ye&&this.Ir(this.Ye.xIdx,this.Ye.yIdx)},onUnpin:()=>{this.emitUnselect()}}}async Ir(n,i){let o=this.St.mode===\"numeric\"&&this.Ft?[this.Ft[n]??null]:this.Zt.map(l=>l.labels[n]??null),r=this.qt.slice(0,this.B.length).map(l=>l.labels[i]??null),s=this.L[0]??\"\";await this.emitClickAndSelect({rowIdx:n+this.bt,columnName:s,groupByValues:o,splitByValues:r})}async uploadAndRender(n,i,o,r){if(this.i=n,o!==0)return;let s=this.L.filter(l=>!!l);if(s.length>1){let l=wu(i,s),a=[],u=[],m=1/0,f=-1/0;for(let c of l){let d=ws({columns:c.columns,numRows:r,groupBy:this.h,splitBy:this.B,groupByTypes:this.vt}),b=u.length;for(let g of d.cells)u.push({xIdx:g.xIdx,yIdx:g.yIdx,value:g.value});a.push({label:c.label,pipeline:d,layout:new oe(1,1,{hasXLabel:!1,hasYLabel:!1,hasLegend:!1}),instanceStart:b,instanceCount:d.cells.length,xOrigin:d.xNumericDomain?.min??0,yOrigin:d.yNumericDomain?.min??0}),isFinite(d.colorMin)&&d.colorMin<m&&(m=d.colorMin),isFinite(d.colorMax)&&d.colorMax>f&&(f=d.colorMax)}!isFinite(m)||!isFinite(f)?(m=0,f=1):m===f&&(f=m+1),this.Zt=[],this.qt=[],this.To=[],this.Mt=0,this.Rt=0,this.bt=0,this.ki=[],this.u=null,this.St={mode:\"category\"},this.Qn={mode:\"category\"},this.Ft=null,this.vn=null,this.nt=null,this.gt=null,this.S=0,this.D=0,this.d=a,this.ot=u,this.p=m,this.c=f,this.Kt=s.join(\", \")}else{let l=ws({columns:i,numRows:r,groupBy:this.h,splitBy:this.B,groupByTypes:this.vt});this.d=[],this.b=null,this.Zt=l.xLevels,this.qt=l.yLevels,this.To=l.yColumnNames,this.Mt=l.numX,this.Rt=l.numY,this.bt=l.rowOffset,this.ot=l.cells,this.ki=l.cells2D,this.p=l.colorMin,this.c=l.colorMax,this.Kt=s[0]??\"Color\",this.St=l.xAxisMode,this.Qn=l.yAxisMode,this.Ft=l.xPositions,this.vn=l.yPositions,this.nt=l.xNumericDomain,this.gt=l.yNumericDomain,this.S=l.xNumericDomain?.min??0,this.D=l.yNumericDomain?.min??0}await this.requestRender(n)}kt(n){this.i=n;let i=this.Mt>0&&this.Rt>0,o=this.d.length>0;!i&&!o||Iu(this,n)}destroyInternal(){this.H&&this.i&&this.i.gl.deleteBuffer(this.H),this.o=null,this.E=null,this.H=null,this.Zt=[],this.qt=[],this.To=[],this.ot=[],this.ki=[],this.Ye=null,this.d=[],this.b=null,this.Jn=-1,this.St={mode:\"category\"},this.Qn={mode:\"category\"},this.Ft=null,this.vn=null,this.nt=null,this.gt=null}};Tn();function ei(){return{count:0,catIdx:new Int32Array(0),splitIdx:new Int32Array(0),seriesId:new Int32Array(0),xCenter:new Float64Array(0),halfWidth:new Float64Array(0),open:new Float64Array(0),close:new Float64Array(0),high:new Float64Array(0),low:new Float64Array(0),isUp:new Uint8Array(0)}}function bd(e,t){return e&&e.catIdx.length>=t?(e.count=0,e):{count:0,catIdx:new Int32Array(t),splitIdx:new Int32Array(t),seriesId:new Int32Array(t),xCenter:new Float64Array(t),halfWidth:new Float64Array(t),open:new Float64Array(t),close:new Float64Array(t),high:new Float64Array(t),low:new Float64Array(t),isUp:new Uint8Array(t)}}var Gu={splitPrefixes:[],rowPaths:[],numCategories:0,rowOffset:0,axisMode:{mode:\"category\"},numericCategoryDomain:null,categoryPositions:null,series:[],yDomain:{min:0,max:1}};function Wu(e){let{columns:t,numRows:n,columnSlots:i,groupBy:o,splitBy:r,groupByTypes:s,bandInnerFrac:l,barInnerPad:a,scratchCandles:u}=e,m=sn(o,s),f=i[0]||\"\";if(!f)return{...Gu,candles:ei()};let c=i[1]||\"\",d=i[2]||\"\",b=i[3]||\"\",g=[];if(r.length>0){let U=[f];c&&U.push(c),d&&U.push(d),b&&U.push(b);for(let Y of it(t,[f],U))Y.colNames.has(f)&&g.push(Y.prefix);g.length===0&&g.push(\"\")}else g.push(\"\");let h=o.map(U=>s[U]??\"string\"),{rowPaths:x,numCategories:y,rowOffset:C}=ln(t,n,o.length,h,m);if(y===0)return{...Gu,axisMode:m,splitPrefixes:g,rowPaths:x,rowOffset:C,candles:ei()};let _=g.length,v=[];for(let U=0;U<_;U++){let Y=g[U];v.push({seriesId:U,splitIdx:U,splitKey:Y,label:Y===\"\"?f:Y})}let A=null,L=null,T=1;if(m.mode===\"numeric\"&&y>0){let U=t.get(\"__ROW_PATH_0__\"),Y=Dt(U?.values,y,C,o[0]??\"\",m.numericType===\"date\"||m.numericType===\"datetime\");Y&&(A=Y.categoryPositions,L=Y.numericCategoryDomain,T=Y.numericCategoryDomain.bandWidth)}let w=No(_,l,a),M=w.slotWidth*T,I=w.halfWidth*T,D=(_-1)/2,S=[];for(let U=0;U<_;U++){let Y=g[U],q=pt=>Y===\"\"?pt:`${Y}|${pt}`,me=t.get(q(f));if(!me?.values){S.push({openCol:null,closeCol:null,highCol:null,lowCol:null,openValid:null,closeValid:null,highValid:null,lowValid:null});continue}let Ge=c?t.get(q(c)):null,Re=d?t.get(q(d)):null,Fe=b?t.get(q(b)):null;S.push({openCol:me.values,closeCol:Ge?.values??null,highCol:Re?.values??null,lowCol:Fe?.values??null,openValid:me.valid??null,closeValid:Ge?.valid??null,highValid:Re?.valid??null,lowValid:Fe?.valid??null})}let E=y*_,k=bd(u??null,E),W=0,V=1/0,N=-1/0,H=y;for(let U=0;U<_;U++){let Y=S[U],q=Y.openCol;if(!q)continue;let me=Y.closeCol,Ge=Y.highCol,Re=Y.lowCol,Fe=Y.openValid,pt=Y.closeValid,bn=Y.highValid,gn=Y.lowValid,hn=(U-D)*M;for(let Ae=0;Ae<H;Ae++){let ae=Ae+C;if(Fe&&!(Fe[ae>>3]>>(ae&7)&1))continue;let ee=q[ae];if(!isFinite(ee))continue;let re;if(me&&(!pt||(pt[ae>>3]>>(ae&7)&1)!==0)){let J=me[ae];re=isFinite(J)?J:ee}else{let J=Ae<H-1?Ae+1+C:ae;if(!Fe||(Fe[J>>3]>>(J&7)&1)!==0){let Pt=q[J];re=isFinite(Pt)?Pt:ee}else re=ee}let We;if(Ge&&(!bn||(bn[ae>>3]>>(ae&7)&1)!==0)){let J=Ge[ae];We=isFinite(J)?J:ee>re?ee:re}else We=ee>re?ee:re;let ke;if(Re&&(!gn||(gn[ae>>3]>>(ae&7)&1)!==0)){let J=Re[ae];ke=isFinite(J)?J:ee<re?ee:re}else ke=ee<re?ee:re;let dr=(A?A[Ae]:Ae)+hn,Ne=re>=ee?1:0;k.catIdx[W]=Ae,k.splitIdx[W]=U,k.seriesId[W]=U,k.xCenter[W]=dr,k.halfWidth[W]=I,k.open[W]=ee,k.close[W]=re,k.high[W]=We,k.low[W]=ke,k.isUp[W]=Ne,W++,ke<V&&(V=ke),We>N&&(N=We)}}if(k.count=W,!isFinite(V)||!isFinite(N))V=0,N=1;else if(V===N){let U=Math.max(Math.abs(V),1)*.05;V-=U,N+=U}return{splitPrefixes:g,rowPaths:x,numCategories:y,rowOffset:C,axisMode:m,numericCategoryDomain:L,categoryPositions:A,series:v,candles:k,yDomain:{min:V,max:N}}}ot();ge();Fn();Nt();be();Dn();Ce();Jt();be();var gd=3;function ku(e,t,n){let i=0,o=t;for(;i<o;){let r=i+o>>>1;e[r]<n?i=r+1:o=r}return i}function Bs(e,t,n){if(e.wo!==-1)return;let i=e.u;if(!i)return;let o=e.Te;if(o.count===0){e.we!==-1&&(e.we=-1,dt(e));return}let r=i.e,s=i.O,l=i.Z,a=i.q,u=i.ee;if(t<r.x||t>r.x+r.width||n<r.y||n>r.y+r.height){e.we!==-1&&(e.we=-1,dt(e));return}let m=s+(t-r.x)/r.width*(l-s),f=u-(n-r.y)/r.height*(u-a),c=r.width/(l-s),d=gd/c,b=o.xCenter,g=o.halfWidth,h=o.open,x=o.close,y=o.high,C=o.low,_=o.count>0?g[0]:0,v=Math.max(_,d),A=ku(b,o.count,m-v),L=ku(b,o.count,m+v+1e-12),T=-1;for(let w=L-1;w>=A;w--){let M=b[w],I=g[w],D=m>=M-I&&m<=M+I,S=Math.abs(m-M)<=d;if(!D&&!S)continue;let E=h[w],k=x[w],W=E<k?E:k,V=E<k?k:E,N=D&&f>=W&&f<=V,H=f>=C[w]&&f<=y[w];if(N||H){T=w;break}}T!==e.we&&(e.we=T,dt(e))}function Nu(e,t){e.w.dismiss(),e.wo=t;let n=e.Te;if(t<0||t>=n.count||!e.u)return;let i=Gs(e,t);if(i.length===0)return;let o=n.xCenter[t],r=(n.high[t]+n.low[t])/2,s=e.u.R(o,r),l=e.u.cssWidth,a=e.u.cssHeight;e.w.pin(i,s,{cssWidth:l,cssHeight:a},ie(e.t)),e.we=-1,dt(e)}function Gs(e,t){let n=[],i=e.Te;if(t<0||t>=i.count)return n;let o=i.catIdx[t],r=i.splitIdx[t],s=i.open[t],l=i.close[t],a=i.high[t],u=i.low[t],m=Ws(e,o);if(m!==\"\"&&n.push([m]),r>=0&&e.ge.length>1){let g=e.ge[r];g&&n.push([g])}let f=e.getColumnFormatter(e.L[0],\"value\"),c=e.getColumnFormatter(e.L[1],\"value\"),d=e.getColumnFormatter(e.L[2],\"value\"),b=e.getColumnFormatter(e.L[3],\"value\");return n.push([\"Open\",f(s)]),n.push([\"Close\",c(l)]),n.push([\"High\",d(a)]),n.push([\"Low\",b(u)]),n}function Ws(e,t){if(e.Le===\"numeric\"&&e.I&&e.V){let n=e.V[t],i=e.h[0];return e.getColumnFormatter(i,\"value\")(n)}if(e.Ie.length>0){let n=[];for(let i of e.Ie){let o=i.labels[t]??\"\";o&&n.push(o)}return n.join(\" \\u203A \")}return`Row ${t+e.bt}`}function Ou(e,t,n,i,o){let r=1/0,s=-1/0,l={cat:0,lo:0,hi:0,skip:!1};for(let u=0;u<e.length;u++)l.skip=!1,i(e[u],l),!l.skip&&(l.cat<t||l.cat>n||(l.lo<r&&(r=l.lo),l.hi>s&&(s=l.hi)));let a=isFinite(r)&&isFinite(s);if(a&&r===s){let u=Math.abs(r)||1;r-=u,s+=u}return o.min=r,o.max=s,o.hasFit=a,o}function ks(e){let n=e.v().N;if(e.Ni===n)return;let i=Se(n,1),o=Se(n,0);e.Oi=[i[0],i[1],i[2]],e.Ui=[o[0],o[1],o[2]],e.Ni=n}function Uu(e){e.Y.bodyWick.invalidateBuffers(e),e.Y.ohlc.invalidateBuffers(e)}function Hu(e,t){e.Y.bodyWick.rebuildBuffers(e,t),e.Y.ohlc.rebuildBuffers(e,t)}function Vu(e,t){let n=t.gl,i=t.dpr,o=n.canvas.width/i,r=n.canvas.height/i;if(o<=0||r<=0||e.ie===0)return;let s=e.v();ks(e);let l=e.Le===\"numeric\",a=l?e.I.min:-.5,u=l?e.I.max:e.ie-.5;e._&&e._.setBaseDomain(a,u,e.ei.min,e.ei.max);let m=e._?e._.getVisibleDomain():{xMin:a,xMax:u,yMin:e.ei.min,yMax:e.ei.max};if(e.Ci&&e._&&!e._.isXDefault()){let C=yd(e,m.xMin,m.xMax);C.hasFit&&(m.yMin=C.min,m.yMax=C.max)}let f=e.h.length>0,c={levels:e.Ie,numRows:e.ie,levelLabels:e.h.slice()},d;if(l)d=new oe(o,r,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:24});else{let v=Math.max(1,o-71-16),A=Xe(c,v);d=new oe(o,r,{hasXLabel:f,hasYLabel:!0,hasLegend:!1,bottomExtra:A})}e.u=d,e._&&e._.updateLayout(d);let b=d.buildProjectionMatrix(m.xMin,m.xMax,m.yMin,m.yMax,\"y\",void 0,void 0,e.ce,0),g=K(m.yMin,m.yMax,6),h=e.L[0]||\"\",x=c,y={min:m.yMin,max:m.yMax,label:h};e.Q&&qo(e.Q,d,g,s,t.dpr),rt(n,d,t.dpr,()=>{e.xi===\"ohlc\"?e.Y.ohlc.draw(e,n,t,b):e.Y.bodyWick.draw(e,n,t,b)}),e.le=x,e.te=y,e.ae=g,e.Ge=l?K(m.xMin,m.xMax,6):null,e._e(()=>dt(e))}function dt(e){hd(e),e.presentOverlay()}function hd(e){if(!e.l||!e.u||!e.te||!e.ae)return;let t=e.v(),n;if(e.Le===\"numeric\"&&e.I&&e.Ge)n={mode:\"numeric\",domain:{min:e.I.min,max:e.I.max,isDate:e.I.isDate,label:e.I.label},ticks:e.Ge};else if(e.le)n={mode:\"category\",domain:e.le};else return;let i=e.L[0]??e.L[1]??e.L[2]??e.L[3],o=e.h[0];Zo(e.l,n,{mode:\"numeric\",domain:e.te,ticks:e.ae},e.u,t,e.i?.dpr??1,void 0,!1,{value:e.getColumnFormatter(i,\"tick\"),category:e.getColumnFormatter(o,\"tick\")}),e.we>=0&&e.we<e.Te.count&&xd(e)}function xd(e){if(!e.l||!e.u)return;let t=e.we,n=e.Te;if(t<0||t>=n.count)return;let i=e.u,o=n.xCenter[t],r=(n.high[t]+n.low[t])/2,s=i.R(o,r),l=Gs(e,t),a=e.v(),u=e.i?.dpr??1,m=e.L[1],f=n.close[t];(m==null||!Number.isFinite(f))&&(m=e.L[0]??e.L[2]??e.L[3],f=n.open[t]);let c=i.R(o,f),d=[],b;if(e.Le===\"numeric\"&&e.I&&e.V?b=(e.getColumnFormatter(e.h[0],\"tick\")??fe(e.I.isDate,e.Ge))(e.V[n.catIdx[t]]):b=Ws(e,n.catIdx[t]),b!==\"\"&&d.push({side:\"bottom\",px:c.px,py:c.py,text:b}),Number.isFinite(f)){let g=e.getColumnFormatter(m,\"tick\")??fe(e.te?.isDate,e.ae);d.push({side:\"left\",px:c.px,py:c.py,text:g(f)})}Ye(e.l,i,a,u,d,e.t.tooltip_opacity),He(e.l,s,l,i,a,u,{...ie(e.t),crosshair:!1,highlightRadius:0})}function yd(e,t,n){let i=e.wt;if(i&&i.xMin===t&&i.xMax===n)return i;let o=i??_d();o.xMin=t,o.xMax=n;let r=e.Te,s=1/0,l=-1/0,a=!1,u=r.xCenter,m=r.low,f=r.high;for(let c=0;c<r.count;c++){let d=u[c];d<t||d>n||(m[c]<s&&(s=m[c]),f[c]>l&&(l=f[c]),a=!0)}return o.min=a?s:0,o.max=a?l:1,o.hasFit=a,e.wt=o,o}function _d(){return{xMin:0,xMax:0,min:0,max:1,hasFit:!1}}Be();de();var or=class{constructor(){p(this,\"o\",null);p(this,\"r\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,i=fo(n),r={...j(t,\"candlestick-body\",di,pi,[\"u_projection\"],[\"a_corner\",\"a_x_center\",\"a_half_width\",\"a_y0\",\"a_y1\",\"a_color\"]),quadBuffer:i,instanceBuffer:n.createBuffer()},s=at(n),a={...j(t,\"line-uniform\",Ke,Je,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_corner\",\"a_start\",\"a_end\",\"a_real_start\",\"a_real_end\"]),cornerBuffer:s,segmentBuffer:n.createBuffer()};return this.o={body:r,wick:a},this.o}invalidateBuffers(t){let n=this.r;if(!n||!t.i){this.r=null;return}let i=t.i.gl;i.deleteBuffer(n.upWickBuffer),i.deleteBuffer(n.downWickBuffer),this.r=null}rebuildBuffers(t,n){let i=t.Te,o=this.ensureProgram(n),r=n.gl,s=t.ce;if(i.count===0){let M=r.createBuffer(),I=r.createBuffer();this.r={bodyCount:0,upWickCount:0,downWickCount:0,upWickBuffer:M,downWickBuffer:I};return}let l=new Float32Array(i.count*7),a=0,u=0,m=i.xCenter,f=i.halfWidth,c=i.open,d=i.close,b=i.isUp,g=t.Oi,h=t.Ui;for(let M=0;M<i.count;M++){let I=c[M],D=d[M],S=I<D?I:D,E=I<D?D:I,k=b[M]!==0,W=k?g:h,V=M*7;l[V+0]=m[M]-s,l[V+1]=f[M]*.7,l[V+2]=S,l[V+3]=E,l[V+4]=W[0],l[V+5]=W[1],l[V+6]=W[2],k?a++:u++}r.bindBuffer(r.ARRAY_BUFFER,o.body.instanceBuffer),r.bufferData(r.ARRAY_BUFFER,l,r.STATIC_DRAW);let x=new Float32Array(a*4),y=new Float32Array(u*4),C=0,_=0,v=i.low,A=i.high;for(let M=0;M<i.count;M++){let I=m[M]-s,D=v[M],S=A[M];b[M]!==0?(x[C+0]=I,x[C+1]=D,x[C+2]=I,x[C+3]=S,C+=4):(y[_+0]=I,y[_+1]=D,y[_+2]=I,y[_+3]=S,_+=4)}let L=this.r,T=L?.upWickBuffer??r.createBuffer(),w=L?.downWickBuffer??r.createBuffer();r.bindBuffer(r.ARRAY_BUFFER,T),r.bufferData(r.ARRAY_BUFFER,x,r.STATIC_DRAW),r.bindBuffer(r.ARRAY_BUFFER,w),r.bufferData(r.ARRAY_BUFFER,y,r.STATIC_DRAW),this.r={bodyCount:i.count,upWickCount:a,downWickCount:u,upWickBuffer:T,downWickBuffer:w}}draw(t,n,i,o){let r=this.r;if(!r||r.bodyCount===0)return;let s=this.ensureProgram(i);Cd(n,i,s.body,r.bodyCount,o),vd(t,n,i,s.wick,r,o)}destroy(t){let n=t.i?.gl;if(n){this.invalidateBuffers(t);let i=this.o;i&&(n.deleteBuffer(i.body.quadBuffer),n.deleteBuffer(i.body.instanceBuffer),n.deleteBuffer(i.wick.cornerBuffer),n.deleteBuffer(i.wick.segmentBuffer))}this.o=null,this.r=null}};function Cd(e,t,n,i,o){if(i===0)return;let r=7*Float32Array.BYTES_PER_ELEMENT;e.useProgram(n.program),e.uniformMatrix4fv(n.u_projection,!1,o);let s=Q(t),{setDivisor:l}=s;e.bindBuffer(e.ARRAY_BUFFER,n.quadBuffer),e.enableVertexAttribArray(n.a_corner),e.vertexAttribPointer(n.a_corner,2,e.FLOAT,!1,0,0),l(n.a_corner,0),e.bindBuffer(e.ARRAY_BUFFER,n.instanceBuffer);let a=Float32Array.BYTES_PER_ELEMENT,u=(m,f,c)=>{e.enableVertexAttribArray(m),e.vertexAttribPointer(m,f,e.FLOAT,!1,r,c),l(m,1)};u(n.a_x_center,1,0),u(n.a_half_width,1,1*a),u(n.a_y0,1,2*a),u(n.a_y1,1,3*a),u(n.a_color,3,4*a),s.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,i),l(n.a_x_center,0),l(n.a_half_width,0),l(n.a_y0,0),l(n.a_y1,0),l(n.a_color,0)}function vd(e,t,n,i,o,r){if(o.upWickCount===0&&o.downWickCount===0)return;let s=n.dpr;t.useProgram(i.program),t.uniformMatrix4fv(i.u_projection,!1,r),t.uniform2f(i.u_resolution,t.canvas.width,t.canvas.height),t.uniform1f(i.u_line_width,e.t.wick_width_px*s),t.disableVertexAttribArray(i.a_real_start),t.disableVertexAttribArray(i.a_real_end),t.vertexAttrib1f(i.a_real_start,1),t.vertexAttrib1f(i.a_real_end,1),t.uniform1f(i.u_interp_alpha,1);let l=Q(n),{setDivisor:a}=l;t.bindBuffer(t.ARRAY_BUFFER,i.cornerBuffer),t.enableVertexAttribArray(i.a_corner),t.vertexAttribPointer(i.a_corner,1,t.FLOAT,!1,0,0),a(i.a_corner,0),zu(t,l,i,o.upWickBuffer,o.upWickCount,e.Oi),zu(t,l,i,o.downWickBuffer,o.downWickCount,e.Ui),a(i.a_start,0),a(i.a_end,0)}function zu(e,t,n,i,o,r){if(o===0)return;let s=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:l}=t;e.uniform4f(n.u_color,r[0],r[1],r[2],1),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,2*s,0),l(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,2*s,s),l(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,o)}Be();de();var rr=class{constructor(){p(this,\"o\",null);p(this,\"r\",null)}ensureProgram(t){if(this.o)return this.o;let n=t.gl,i=at(n),o=j(t,\"line-uniform\",Ke,Je,[\"u_projection\",\"u_color\",\"u_resolution\",\"u_line_width\",\"u_interp_alpha\"],[\"a_corner\",\"a_start\",\"a_end\",\"a_real_start\",\"a_real_end\"]);return this.o={...o,cornerBuffer:i,segmentBuffer:n.createBuffer()},this.o}invalidateBuffers(t){let n=this.r;if(!n||!t.i){this.r=null;return}let i=t.i.gl;i.deleteBuffer(n.upBuffer),i.deleteBuffer(n.downBuffer),this.r=null}rebuildBuffers(t,n){if(t.xi!==\"ohlc\")return;let i=t.Te,o=n.gl;this.ensureProgram(n);let r=t.ce,s=i.xCenter,l=i.halfWidth,a=i.open,u=i.close,m=i.high,f=i.low,c=i.isUp,d=0,b=0;for(let A=0;A<i.count;A++)c[A]!==0?d++:b++;let g=new Float32Array(d*3*4),h=new Float32Array(b*3*4),x=0,y=0;for(let A=0;A<i.count;A++){let L=s[A]-r,T=a[A],w=u[A],M=f[A],I=m[A],D=l[A],S=c[A]!==0?g:h,E=c[A]!==0?x:y;S[E++]=L,S[E++]=M,S[E++]=L,S[E++]=I,S[E++]=L-D,S[E++]=T,S[E++]=L,S[E++]=T,S[E++]=L,S[E++]=w,S[E++]=L+D,S[E++]=w,c[A]!==0?x=E:y=E}let C=this.r,_=C?.upBuffer??o.createBuffer(),v=C?.downBuffer??o.createBuffer();o.bindBuffer(o.ARRAY_BUFFER,_),o.bufferData(o.ARRAY_BUFFER,g,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,v),o.bufferData(o.ARRAY_BUFFER,h,o.STATIC_DRAW),this.r={upBuffer:_,downBuffer:v,upInstanceCount:d*3,downInstanceCount:b*3}}draw(t,n,i,o){let r=this.r;if(!r||r.upInstanceCount===0&&r.downInstanceCount===0)return;let s=this.ensureProgram(i),l=i.dpr;n.useProgram(s.program),n.uniformMatrix4fv(s.u_projection,!1,o),n.uniform2f(s.u_resolution,n.canvas.width,n.canvas.height),n.uniform1f(s.u_line_width,t.t.ohlc_line_width_px*l),n.disableVertexAttribArray(s.a_real_start),n.disableVertexAttribArray(s.a_real_end),n.vertexAttrib1f(s.a_real_start,1),n.vertexAttrib1f(s.a_real_end,1),n.uniform1f(s.u_interp_alpha,1);let a=Q(i),{setDivisor:u}=a;n.bindBuffer(n.ARRAY_BUFFER,s.cornerBuffer),n.enableVertexAttribArray(s.a_corner),n.vertexAttribPointer(s.a_corner,1,n.FLOAT,!1,0,0),u(s.a_corner,0),Yu(n,a,s,r.upBuffer,r.upInstanceCount,t.Oi),Yu(n,a,s,r.downBuffer,r.downInstanceCount,t.Ui),u(s.a_start,0),u(s.a_end,0)}destroy(t){let n=t.i?.gl;if(n){this.invalidateBuffers(t);let i=this.o;i&&(n.deleteBuffer(i.cornerBuffer),n.deleteBuffer(i.segmentBuffer))}this.o=null,this.r=null}};function Yu(e,t,n,i,o,r){if(o===0)return;let s=4*Float32Array.BYTES_PER_ELEMENT,l=2*Float32Array.BYTES_PER_ELEMENT,{setDivisor:a}=t;e.uniform4f(n.u_color,r[0],r[1],r[2],1),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(n.a_start),e.vertexAttribPointer(n.a_start,2,e.FLOAT,!1,s,0),a(n.a_start,1),e.enableVertexAttribArray(n.a_end),e.vertexAttribPointer(n.a_end,2,e.FLOAT,!1,s,l),a(n.a_end,1),t.drawArraysInstanced(e.TRIANGLE_STRIP,0,4,o)}var ti=class extends un{constructor(){super(...arguments);p(this,\"E\",null);p(this,\"ge\",[]);p(this,\"f\",[]);p(this,\"Te\",ei());p(this,\"ei\",{min:0,max:1});p(this,\"Hi\",null);p(this,\"Le\",\"category\");p(this,\"I\",null);p(this,\"V\",null);p(this,\"Ge\",null);p(this,\"ce\",0);p(this,\"Oi\",[0,.8,.4]);p(this,\"Ui\",[.8,.2,.2]);p(this,\"Ni\",null);p(this,\"we\",-1);p(this,\"wo\",-1);p(this,\"Y\",{bodyWick:new or,ohlc:new rr});p(this,\"Ci\",!0);p(this,\"wt\",null)}tooltipCallbacks(){return{onHover:(n,i)=>Bs(this,n,i),onLeave:()=>{this.we!==-1&&(this.we=-1,dt(this))},onPin:(n,i)=>{if(Bs(this,n,i),this.we>=0){let o=this.we;Nu(this,o),this.Er(o)}},onUnpin:()=>{this.emitUnselect()}}}async Er(n){if(n<0||n>=this.Te.count)return;let i=this.Te.catIdx[n],o=this.Te.splitIdx[n],r=this.Le===\"numeric\"&&this.V?[this.V[i]??null]:this.Ie.map(u=>u.labels[i]??null),s=this.ge[o]??\"\",l=this.B.length>0&&s!==\"\"?s.split(\"|\"):[],a=this.L[1]||this.L.find(u=>!!u)||\"\";await this.emitClickAndSelect({rowIdx:i+this.bt,columnName:a,groupByValues:r,splitByValues:l})}invalidateTheme(){super.invalidateTheme(),this.Ni=null}async uploadAndRender(n,i,o,r){if(this.i=n,o!==0)return;let s=Wu({columns:i,numRows:r,columnSlots:this.L,groupBy:this.h,splitBy:this.B,groupByTypes:this.vt,bandInnerFrac:this.t.band_inner_frac,barInnerPad:this.t.bar_inner_pad,scratchCandles:this.Te});this.t.domain_mode===\"expand\"?this.Hi=Qn(this.Hi,s.yDomain):this.Hi=null,this.Ie=s.rowPaths,this.ie=s.numCategories,this.bt=s.rowOffset,this.ge=s.splitPrefixes,this.f=s.series,this.Te=s.candles,this.ei=s.yDomain,this.Le=s.axisMode.mode,this.I=s.numericCategoryDomain,this.V=s.categoryPositions,this.ce=s.numericCategoryDomain?.min??0,this.wt=null,ks(this),Uu(this),Hu(this,n),await this.requestRender(n)}kt(n){this.i=n,Vu(this,n)}resetExpandedDomain(){this.Hi=null}destroyInternal(){if(this.i){let n=this.i.gl;this.H&&n.deleteBuffer(this.H),this.Y.bodyWick.destroy(this),this.Y.ohlc.destroy(this)}this.o=null,this.E=null,this.H=null,this.Te=ei(),this.f=[],this.Ie=[],this.ie=0,this.Ni=null}};var Zu={scatter:async()=>co,line:async()=>po,density:async()=>bo,treemap:async()=>Po,sunburst:async()=>ko,heatmap:async()=>ir,\"y-bar\":async()=>ct,\"y-line\":async()=>ct,\"y-scatter\":async()=>ct,\"y-area\":async()=>ct,\"x-bar\":async()=>tr,candlestick:async()=>ti,ohlc:async()=>ti,\"map-scatter\":async()=>(await Promise.resolve().then(()=>(mr(),ur))).MapScatterChart,\"map-line\":async()=>(await Promise.resolve().then(()=>(mr(),ur))).MapLineChart,\"map-density\":async()=>(await Promise.resolve().then(()=>(mr(),ur))).MapDensityChart};async function qu(e,t,n){let i=new Map;await e.with_typed_arrays(n??{},async(o,r,s,l)=>{for(let u=0;u<o.length;u++){let m=o[u],f=r[u],c=s[u]??void 0,d=l[u];d!==null?i.set(m,{type:\"string\",indices:f,dictionary:d,valid:c}):f instanceof Float32Array?i.set(m,{type:\"float32\",values:f,valid:c}):f instanceof Int32Array?i.set(m,{type:\"int32\",values:f,valid:c}):f instanceof Float64Array?i.set(m,{type:\"float64\",values:f,valid:c}):i.set(m,{type:\"float32\",values:new Float32Array(f),valid:c})}let a=0;if(i.size>0){a=1/0;for(let u of i.values()){let m=u.indices?.length??u.values?.length??0;m<a&&(a=m)}}await t(i,a)})}Ei();var Ku=new Map;async function Ju(e){let t=[e.family,e.src,e.weight??\"\",e.style??\"\"].join(\"|\"),n=Ku.get(t);if(n){await n;return}n=(async()=>{try{let i={};e.style&&(i.style=e.style),e.weight&&(i.weight=e.weight),e.stretch&&(i.stretch=e.stretch);let o=new FontFace(e.family,e.src,i);await o.load(),self.fonts.add(o)}catch(i){console.warn(`Failed to load font ${e.family}:`,i)}})(),Ku.set(t,n),await n}function pn(e,t){switch(t.kind){case\"setViewByName\":e.setViewByName(t.name);break;case\"setColumnsConfig\":e.chartImpl.setColumnsConfig?.(t.cfg);break;case\"setPluginConfig\":e.setPluginConfig(t.cfg,t.tileSource),e.redraw();break;case\"setBufferMaxCapacity\":e.glManager.A.maxCapacity=t.n;break;case\"loadAndRender\":e.loadAndRender(t);break;case\"redraw\":e.redraw();break;case\"deselect\":e.chartImpl.deselect?.();break;case\"resize\":e.resize(t.cssWidth,t.cssHeight,t.dpr),e.redrawAck(t.msgId);break;case\"clear\":e.clear();break;case\"invalidateTheme\":e.chartImpl.setTheme?.(t.themeVars),e.chartImpl.invalidateTheme?.(),e.resize(e.cssWidth,e.cssHeight,e.dpr);break;case\"restoreZoom\":e.restoreZoom(t.state);break;case\"resetAllZooms\":e.resetAllZooms(),e.redraw(),e.post({kind:\"zoomChanged\",isDefault:e.allZoomsDefault()});break;case\"resetExpandedDomain\":e.resetExpandedDomain();break;case\"interaction\":e.onInteraction(t.event);break;case\"saveZoom\":e.post({kind:\"saveZoomReply\",requestId:t.requestId,state:e.saveZoom()});break;case\"destroy\":e.destroy();break;case\"init\":break;case\"snapshotPng\":{let n=t.requestId;e.snapshotPng().then(i=>{e.post({kind:\"snapshotPngReply\",requestId:n,blob:i})}).catch(i=>{e.post({kind:\"snapshotPngReply\",requestId:n,error:String(i)})});break}}}var ni=new Map,Hs=new Set;function Vs(e,t,n){let i={sessionId:e,msg:t};n&&n.length>0?self.postMessage(i,n):self.postMessage(i)}function Ad(e){return{postMessage:(t,n)=>Vs(e,t,n),addEventListener:()=>{},removeEventListener:()=>{},start:()=>{},close:()=>{},dispatchEvent:()=>!1,onmessage:null,onmessageerror:null}}function Qu(e){self.addEventListener(\"message\",function(t){let n=t.data,{sessionId:i,msg:o}=n;if(o.kind===\"init\"){if(ni.has(i)){Vs(i,{kind:\"error\",message:`sessionId ${i} already initialized`});return}e(o,Ad(i)).then(s=>{if(Hs.delete(i)){pn(s,{kind:\"destroy\"});return}ni.set(i,s)}).catch(s=>{Hs.delete(i),Vs(i,{kind:\"error\",message:String(s)})});return}if(o.kind===\"destroy\"){let s=ni.get(i);s?(pn(s,o),ni.delete(i)):Hs.add(i);return}let r=ni.get(i);r&&pn(r,o)})}Or();var fr=class extends Error{constructor(){super(\"StaleGenerationError\")}};async function tm(e){let t=Zu[e];if(!t)throw new Error(`Unknown chart tag: ${e}`);return await t()}var zs=null;function Ld(e){return zs||(zs=new Mi(4,{precompile:e})),zs}var cr=class{constructor(t,n,i,o,r,s){p(this,\"chartImpl\");p(this,\"glManager\");p(this,\"zoomController\",null);p(this,\"gridlines\");p(this,\"chrome\");p(this,\"cssWidth\");p(this,\"cssHeight\");p(this,\"dpr\");p(this,\"Vi\",null);p(this,\"Cr\",null);p(this,\"An\",null);p(this,\"Mo\",0);p(this,\"Ro\",!1);p(this,\"client\");p(this,\"view\");p(this,\"table\");p(this,\"controlPort\");p(this,\"Fo\",0);p(this,\"Ln\",null);p(this,\"So\",0);p(this,\"Do\",0);if(this.client=n,this.view=i,this.table=o,this.controlPort=r,this.chartImpl=new s,t.tileSource&&et.register(t.tileSource),t.renderMode===\"blit\"&&!t.glCanvas&&!0)this.glManager=new _n(Ld(t.precompileShaders??!1).acquire());else{let m=t.glCanvas??new OffscreenCanvas(Math.max(1,Math.round(t.cssWidth*t.dpr)),Math.max(1,Math.round(t.cssHeight*t.dpr)));this.glManager=new _n(m,{precompile:t.precompileShaders??!1})}let a=Math.max(1,Math.round(t.cssWidth*t.dpr)),u=Math.max(1,Math.round(t.cssHeight*t.dpr));this.gridlines=t.gridlinesCanvas??new OffscreenCanvas(a,u),this.chrome=t.chromeCanvas??new OffscreenCanvas(a,u),t.renderMode===\"blit\"&&(this.glManager.setFrameCallback(m=>{this.Mo+=1;let f=this.vr(m);this.post({kind:\"frameBitmap\",bitmap:f},[f])}),this.chartImpl.setOverlayPresenter?.(()=>this.kr())),this.cssWidth=t.cssWidth,this.cssHeight=t.cssHeight,this.dpr=t.dpr,this.chartImpl.setGridlineCanvas?.(this.gridlines),this.chartImpl.setChromeCanvas?.(this.chrome),this.chartImpl.setTheme?.(t.themeVars),t.defaultChartType&&this.chartImpl.setDefaultChartType?.(t.defaultChartType),this.chartImpl.setFacetConfig?.(t.facetConfig),this.chartImpl.setPluginConfig?.(t.pluginConfig),t.columnsConfig&&this.chartImpl.setColumnsConfig?.(t.columnsConfig),this.chartImpl.setZoomController&&(this.zoomController=new kt,this.chartImpl.setZoomController(this.zoomController)),this.chartImpl.setView?.(i),this.glManager.A.maxCapacity=t.bufferMaxCapacity,this.glManager.resize(t.cssWidth,t.cssHeight,t.dpr),this.chartImpl.attachTooltip?.(new Di(m=>this.post(m)))}setViewByName(t){this.view=this.client.__unsafe_open_view(t),this.chartImpl.setView?.(this.view)}setPluginConfig(t,n){n&&et.register(n),this.chartImpl.setPluginConfig?.(t)}async loadAndRender(t){let n=++this.Fo,i;try{let[o,r,s,l]=await Promise.all([this.view.num_rows(),this.view.schema(),this.view.expression_schema(),this.table?.schema()??Promise.resolve({})]);if(this.Fo!==n)return;this.chartImpl.setViewPivots?.(t.viewerConfig.group_by,t.viewerConfig.split_by),this.chartImpl.setColumnTypes?.(r),this.chartImpl.setGroupByTypes?.({...l,...s}),this.chartImpl.setColumnSlots?.(t.viewerConfig.columns);let a=Object.keys(r).length||1,u=Math.floor(this.glManager.A.maxCapacity/a),m=Math.min(o,u);this.glManager.ensureBufferCapacity(m);try{await qu(this.view,async(f,c)=>{if(this.Fo!==n)throw new fr;await this.chartImpl.uploadAndRender(this.glManager,f,0,Math.min(m,c))},{end_row:m,float32:t.options.float32})}catch(f){if(!(f instanceof fr))throw f}}catch(o){(o+\"\").indexOf(\"View not found\")===-1&&(console.error(\"loadAndRender failed\",o),i=String(o))}finally{this.post({kind:\"loadAndRenderAck\",msgId:t.msgId,error:i})}}redraw(){this.chartImpl.requestRender(this.glManager)}redrawAck(t){this.chartImpl.requestRender(this.glManager).catch(()=>{}).finally(()=>this.post({kind:\"resizeAck\",msgId:t}))}resize(t,n,i){this.cssWidth=t,this.cssHeight=n,this.dpr=i,this.glManager.requestResize(t,n,i),this.chartImpl.requestRender(this.glManager)}clear(){El(this.glManager,()=>{this.glManager.clear(),this.gridlines.getContext(\"2d\")?.clearRect(0,0,this.gridlines.width,this.gridlines.height)})}saveZoom(){return this.zoomController?.serialize()}restoreZoom(t){t&&this.zoomController?.restore(t)}allZoomsDefault(){if(this.zoomController&&!this.zoomController.isDefault())return!1;let t=this.chartImpl?.Sn;if(t){for(let n of t)if(n&&!n.isDefault())return!1}return!0}resetAllZooms(){this.zoomController?.reset();let t=this.chartImpl?.Sn;if(t)for(let n of t)n?.reset();this.resetExpandedDomain()}resetExpandedDomain(){this.chartImpl.resetExpandedDomain?.()}Ar(t,n){let i=this.chartImpl,o=i?.b;if(o){for(let l=0;l<o.cells.length;l++){let a=o.cells[l],u=a.layout.e;if(t>=u.x&&t<=u.x+u.width&&n>=u.y&&n<=u.y+u.height){let m=i.getZoomControllerForFacet?.(l)??this.zoomController;return m?{controller:m,layout:a.layout}:null}}return null}if(!this.zoomController)return null;let r=i?.u;if(!r)return null;let s=r.e;return t<s.x||t>s.x+s.width||n<s.y||n>s.y+s.height?null:{controller:this.zoomController,layout:r}}Nr(t){let n=this.chartImpl,i=n?.F,o=n?.t;return!i||!o?!1:i.handleEvent(t,{cfg:o,cssWidth:this.cssWidth,cssHeight:this.cssHeight,legendRects:n._n??[],repaint:r=>{!r&&typeof n.repaintChrome==\"function\"?n.repaintChrome():this.chartImpl.requestRender(this.glManager)},postDelta:r=>this.post({kind:\"pluginConfigDelta\",fields:r}),setCursor:r=>n.yi?.setCursor?.(r),dispatchLeave:()=>this.w()?.dispatchLeave()})}onInteraction(t){try{this.Or(t)}catch(n){this.Ln=null,this.chartImpl?.F?.cancelGesture?.(),console.error(\"interaction dispatch failed\",n)}}Or(t){if(!(!(this.Ln!==null&&(t.type===\"pointermove\"||t.type===\"pointerup\"))&&this.Nr(t)))switch(t.type){case\"wheel\":{let i=this.Ar(t.mx,t.my);if(!i)return;el(i,t.mx,t.my,t.deltaY),this.chartImpl.requestRender(this.glManager),this.post({kind:\"zoomChanged\",isDefault:this.allZoomsDefault()});break}case\"pointerdown\":{let i=this.Ar(t.mx,t.my);if(!i)return;this.Ln=i,this.So=t.mx,this.Do=t.my;break}case\"pointermove\":{if(this.Ln){let i=t.mx-this.So,o=t.my-this.Do;this.So=t.mx,this.Do=t.my,tl(this.Ln,i,o),this.chartImpl.requestRender(this.glManager),this.post({kind:\"zoomChanged\",isDefault:this.allZoomsDefault()})}else this.w()?.dispatchHover(t.mx,t.my);break}case\"pointerup\":{this.Ln=null;break}case\"pointerleave\":{this.w()?.dispatchLeave();break}case\"click\":{this.w()?.dispatchClick(t.mx,t.my);break}case\"dblclick\":{this.w()?.dispatchDblClick(t.mx,t.my);break}}}w(){return this.chartImpl?.w??null}vr(t){let n=t.width,i=t.height;this.Vi||(this.Vi=new OffscreenCanvas(n,i),this.Cr=this.Vi.getContext(\"2d\"));let o=this.Vi,r=this.Cr;return r?(o.width!==n||o.height!==i?(o.width=n,o.height=i):r.clearRect(0,0,n,i),this.gridlines.width===n&&this.gridlines.height===i&&r.drawImage(this.gridlines,0,0),r.drawImage(t,0,0),this.An!==t&&(this.An?.close(),this.An=t),this.chrome.width===n&&this.chrome.height===i&&r.drawImage(this.chrome,0,0),o.transferToImageBitmap()):t}kr(){if(this.Ro)return;this.Ro=!0;let t=this.Mo;queueMicrotask(()=>{this.Ro=!1;let n=this.An;if(this.Mo!==t||!n)return;let i=Math.max(1,Math.round(this.cssWidth*this.dpr)),o=Math.max(1,Math.round(this.cssHeight*this.dpr));if(n.width!==i||n.height!==o)return;let r=this.vr(n);r!==n&&this.post({kind:\"frameBitmap\",bitmap:r},[r])})}async snapshotPng(){this.glManager.beginFrame(),this.chartImpl.renderFrameSync(this.glManager);let t=this.glManager.gl,n=t.canvas,i=n.width,o=n.height,r=new Uint8ClampedArray(i*o*4);t.readPixels(0,0,i,o,t.RGBA,t.UNSIGNED_BYTE,r);let s=new OffscreenCanvas(i,o),l=s.getContext(\"2d\");if(!l)throw new Error(\"snapshotPng: 2D context unavailable\");let u=this.chartImpl.v?.()?.backgroundColor??\"transparent\";u!==\"transparent\"&&(l.fillStyle=u,l.fillRect(0,0,i,o)),l.drawImage(this.gridlines,0,0);let m=new OffscreenCanvas(i,o),f=m.getContext(\"2d\");if(!f)throw new Error(\"snapshotPng: 2D context unavailable for GL blit\");return f.putImageData(new ImageData(r,i,o),0,0),l.save(),l.scale(1,-1),l.drawImage(m,0,-o),l.restore(),l.drawImage(this.chrome,0,0),await s.convertToBlob({type:\"image/png\"})}destroy(){Pl(this.glManager),this.An?.close(),this.An=null,this.chartImpl.destroy(),this.glManager.destroy()}post(t,n){n&&n.length>0?this.controlPort.postMessage(t,n):this.controlPort.postMessage(t)}},Td=typeof globalThis.importScripts==\"function\";async function wd(e,t){if(!e.clientWorkerURL||!e.clientWasm||!e.proxyPort)throw new Error(\"Init error\");let n=await import(e.clientWorkerURL.toString());await n.initSync({module:e.clientWasm}),e.fontFaces?.length&&await Promise.all(e.fontFaces.map(Ju));let i=e.proxyPort,o=new n.Client(async u=>{let m=u.slice().buffer;i.postMessage(m,[m])},async()=>i.close());i.addEventListener(\"message\",u=>{o.handle_response(new Uint8Array(u.data))}),i.start();let r=o.__unsafe_open_view(e.viewName),s=e.tableName?await o.open_table(e.tableName):null,l=await tm(e.chartTag),a=new cr(e,o,r,s,t,l);return a.post({kind:\"ready\"}),a}async function av(e){let t=e.client.__unsafe_open_view(e.msg.viewName),n=e.msg.tableName?await e.client.open_table(e.msg.tableName):null,i=await tm(e.msg.chartTag),o=new cr(e.msg,e.client,t,n,e.controlPort,i);return e.controlPort.addEventListener(\"message\",r=>{let s=r.data;s?.kind!==\"init\"&&pn(o,s)}),e.controlPort.start(),o.post({kind:\"ready\"}),o}Td&&Qu(wd);export{cr as WorkerRenderer,av as bootstrapInProcess};\n", "\n import workerSource from \"../worker/renderer.worker.js\";\n let cached = null;\n export async function getWorkerURL() {\n if (cached) return cached;\n const blob = new Blob([workerSource], {\n type: \"application/javascript\",\n });\n\n cached = URL.createObjectURL(blob);\n return cached;\n }\n\n function make_host(a, b) {\n return {\n addEventListener(type, callback) {\n if (type === \"message\") {\n a.push(callback);\n }\n },\n removeEventListener(type, callback) {\n const idx = a.indexOf(callback);\n if (idx > -1) {\n a.splice(idx, 1);\n }\n },\n postMessage(msg, ports) {\n for (const listener of b) {\n listener({\n data: msg,\n ports: ports,\n });\n }\n },\n terminate() {},\n location: { href: \"\" },\n };\n }\n\n function run_single_threaded() {\n console.warn(\n \"Running perspective in single-threaded mode\"\n );\n const f = Function(\n \"const self = arguments[0];\" + workerSource\n );\n const workers = [];\n const mains = [];\n f(make_host(workers, mains));\n return make_host(mains, workers);\n }\n\n export async function initialize(opts) {\n const workerOpts = opts || {\n type: \"module\",\n };\n try {\n if (\n typeof window !== \"undefined\" &&\n window.location &&\n window.location.protocol &&\n window.location.protocol.startsWith(\n \"file\"\n )\n ) {\n console.warn(\n \"file:// protocol does not reliably support Web Workers\"\n );\n return run_single_threaded();\n }\n\n const url = await getWorkerURL();\n const worker = new Worker(url, workerOpts);\n return worker;\n } catch (e) {\n console.error(\n \"Error instantiating worker; falling back to single-threaded mode\",\n e\n );\n return run_single_threaded();\n }\n }\n\n export default getWorkerURL;\n ", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport type { Client, View, ViewConfig } from \"@perspective-dev/client\";\nimport type { FacetConfig, PluginConfig } from \"../charts/chart\";\nimport type {\n ControlMsg,\n ErrorMsg,\n InitMsg,\n InteractionEvent,\n LoadAndRenderMsg,\n WorkerEnvelope,\n WorkerMsg,\n} from \"./protocol\";\nimport {\n PerspectiveSelectDetail,\n type PerspectiveClickDetail,\n} from \"../event-detail\";\nimport { snapshotThemeVars } from \"../theme/theme-snapshot\";\nimport { snapshotFontFaces } from \"../utils/font-snapshot\";\nimport { TILE_SOURCES } from \"../map/tile-source\";\nimport { DomHostSink } from \"../interaction/host-sink-dom\";\nimport { RUNTIME_MODE } from \"../config\";\n\n// @ts-ignore \u2014 resolved at build time by `@perspective-dev/esbuild-plugin/worker`\nimport getWorkerURL from \"../worker/renderer.worker.js\";\n\n/**\n * Module-level shared `Worker` for every `RendererTransport` running\n * in worker mode. One worker process hosts one `WorkerRenderer` per\n * active `sessionId` \u2014 N chart instances share startup costs (wasm\n * `initSync`, font loads, JS module parse) instead of paying them N\n * times.\n *\n * Lazy: created on first `transport.init()` in worker mode. Lives\n * until page teardown \u2014 no refcount, no termination logic. Pages\n * with no charts never spawn one. Per-session memory still scales\n * with N (each session retains its own WebGL context, buffer pool,\n * chart impl, view, client); the browser's ~16-context-per-worker\n * cap is the new ceiling on simultaneous worker-mode charts.\n *\n * In-process mode bypasses this entirely \u2014 each transport gets its\n * own `MessageChannel` + in-thread `WorkerRenderer`.\n */\nlet SHARED_WORKER: Promise<Worker> | null = null;\n\n/**\n * Per-session message handlers, keyed by the host-allocated\n * `sessionId`. The shared worker's response listener demultiplexes\n * incoming envelopes into here.\n */\nconst HOST_LISTENERS = new Map<number, (msg: WorkerMsg) => void>();\n\nlet NEXT_SESSION_ID = 0;\n\nasync function getSharedWorker(): Promise<Worker> {\n if (SHARED_WORKER) {\n return SHARED_WORKER;\n }\n\n SHARED_WORKER = (async () => {\n const url = await getWorkerURL();\n const w = new Worker(url, { type: \"module\", name: \"viewer-charts\" });\n w.addEventListener(\"message\", (e: MessageEvent) => {\n const env = e.data as WorkerEnvelope;\n HOST_LISTENERS.get(env.sessionId)?.(env.msg);\n });\n\n let poisoned = false;\n w.addEventListener(\"error\", (event: ErrorEvent) => {\n if (poisoned) {\n return;\n }\n\n poisoned = true;\n SHARED_WORKER = null;\n const detail = event.message || `failed to load ${url}`;\n const message = `perspective-viewer-charts renderer worker error: ${detail}`;\n console.error(message, event.error ?? \"\");\n const errorMsg: ErrorMsg = { kind: \"error\", message };\n for (const listener of HOST_LISTENERS.values()) {\n listener(errorMsg);\n }\n });\n\n return w;\n })();\n\n return SHARED_WORKER;\n}\n\ninterface RendererHandle {\n post(msg: any, transfer: Transferable[]): void;\n addMessageListener(cb: (msg: any) => void): void;\n terminate(): void;\n}\n\ntype PendingRenderType =\n | \"saveZoom\"\n | \"loadAndRender\"\n | \"snapshotPng\"\n | \"resize\";\ninterface PendingRenderRequest {\n kind: PendingRenderType;\n resolve: (v: any) => void;\n reject: (e: Error) => void;\n}\n\n/**\n * Unified host-side driver for the chart renderer. Owns one of two\n * handle shapes:\n *\n * - **Worker mode**: a real `Worker` running the same module. The\n * handle posts `ControlMsg`s over `Worker.postMessage`.\n * - **In-process mode**: a `MessageChannel` whose `port2` is owned\n * by an in-thread `WorkerRenderer` instantiated via\n * `await import(workerURL)`. Same module bytes, different host.\n *\n * Both modes go through the same control channel, the same\n * `ProxySession` proxy port, and the same `OffscreenCanvas` transfer\n * \u2014 `MessageChannel` and `transferControlToOffscreen` work in-realm\n * just as well as cross-thread. The only branching is at construction\n * (handle creation) and bootstrap (worker scope sets up its own\n * `Client`; in-process reuses the host's).\n */\nexport class RendererTransport {\n private _handle: RendererHandle | null = null;\n\n /**\n * Set by {@link destroy}. Requests allocated after teardown settle\n * immediately in `_allocPending` \u2014 `_post` is already a no-op once\n * `_handle` is null, so a late request would otherwise never\n * receive its reply and pend forever.\n */\n private _destroyed = false;\n private _proxyChannel: MessageChannel | null = null;\n private _proxySession: any = null;\n private _client: Client;\n private _view: View;\n private _tableName: string | undefined;\n /** Source panel `slot`, tagged onto dispatched interaction events so the\n * host can route them (master/detail, global filter) to the right panel. */\n private _panel: string | undefined;\n private _clientWorkerURL: URL;\n private _clientWasm: WebAssembly.Module;\n private _chartTag: string;\n private _maxCells: number;\n private _precompileShaders: boolean;\n private _ready: Promise<void>;\n private _resolveReady!: () => void;\n private _rejectReady!: (err: Error) => void;\n\n /**\n * Pending request/reply promises across all worker round-trips \u2014\n * `saveZoom`, `uploadChunk` ACKs, and `snapshotPng`. Each entry\n * carries its `kind` so `destroy()` can apply per-kind teardown\n * semantics (uploadChunk resolves silently, the rest reject with\n * a teardown error).\n *\n * Keyed by a single monotonic counter; the worker's reply messages\n * carry that id back verbatim. One counter for all kinds is safe\n * because the host's switch already keys on `msg.kind` before\n * resolving.\n */\n private _pending = new Map<number, PendingRenderRequest>();\n\n private _pendingCounter = 0;\n private _onZoomChanged: ((isDefault: boolean) => void) | null = null;\n\n private _onPluginConfigDelta:\n | ((fields: Record<string, string | number | boolean>) => void)\n | null = null;\n\n /**\n * Cached zoom-default flag pushed by the renderer after each zoom\n * mutation. Surfaced sync via `allZoomsDefault()`; updates between\n * calls are best-effort.\n */\n private _allZoomsDefault = true;\n private _hostGlCanvas: HTMLCanvasElement | null = null;\n\n /**\n * Blit-mode only: the visible `.webgl-canvas`'s 2D context. The\n * worker emits each completed GL frame as a `FrameBitmapMsg`; on\n * receipt we `drawImage` the bitmap into this context and `close()`\n * it to release the GPU surface. Null in direct mode (the visible\n * canvas's drawing buffer is the worker's transferred GL canvas).\n */\n private _displayCtx: CanvasRenderingContext2D | null = null;\n\n /**\n * Present-hold state for the staged-present presize protocol\n * ({@link presize}). While holding, inbound `frameBitmap`s are\n * STAGED (latest wins) instead of blitted, so the on-screen frame\n * \u2014 old dimensions in the old, unchanged box \u2014 stays put until the\n * host invokes the present closure `presize` resolved to, in the\n * same task as its layout commit. Entered only by `presize`;\n * exited by the present closure, by `presize`'s rejection path, or\n * by `destroy` \u2014 every settle path releases the hold or hands the\n * caller the release.\n */\n /**\n * The last `(cssWidth, cssHeight, dpr)` posted to the worker \u2014 at init\n * or any resize \u2014 i.e. the dimensions the worker has already rendered\n * (or has an in-flight render for). {@link resize} short-circuits when\n * its measurement matches (\u00B10.5px, the presize protocol's own\n * threshold): reactive resizes fan in from several host paths per\n * layout transition (the post-commit fan-out, activation nudges, the\n * fresh-restore tail), and every worker resize is an unconditional\n * full re-render.\n */\n private _lastPostedSize: {\n cssWidth: number;\n cssHeight: number;\n dpr: number;\n } | null = null;\n\n private _holdPresent = false;\n\n private _stagedFrame: ImageBitmap | null = null;\n\n /**\n * Host-side sink for tooltip + cursor side-effects. The chart\n * inside the renderer calls into a `MessageHostSink` that posts\n * `pinTooltip` / `dismissTooltip` / `setCursor` over the control\n * channel; this sink applies them to the DOM. Initialized lazily\n * on first signal so we don't pay for the parent-style lookup\n * unless a user interacts.\n */\n private _hostSink: DomHostSink | null = null;\n\n /**\n * Last `insertConfig` accepted by a `userSelect { selected: true }`\n * message. Used to populate `removeConfigs` on the next\n * `selected: false` (unpin / drill-up / view-change) \u2014 mirrors\n * datagrid's `model._last_insert_configs` so coordinated-filter\n * consumers can roll back the previous select when a new one\n * supplants it.\n */\n private _lastInsertConfig: Partial<ViewConfig> | undefined = undefined;\n\n constructor(opts: {\n client: Client;\n view: View;\n tableName?: string;\n panel?: string;\n clientWasm: WebAssembly.Module;\n clientWorkerURL: URL;\n chartTag: string;\n maxCells: number;\n precompileShaders?: boolean;\n onZoomChanged?: (isDefault: boolean) => void;\n onPluginConfigDelta?: (\n fields: Record<string, string | number | boolean>,\n ) => void;\n }) {\n this._client = opts.client;\n this._view = opts.view;\n this._tableName = opts.tableName;\n this._panel = opts.panel;\n this._clientWorkerURL = opts.clientWorkerURL;\n this._clientWasm = opts.clientWasm;\n this._chartTag = opts.chartTag;\n this._maxCells = opts.maxCells;\n this._precompileShaders = opts.precompileShaders ?? false;\n this._onZoomChanged = opts.onZoomChanged ?? null;\n this._onPluginConfigDelta = opts.onPluginConfigDelta ?? null;\n this._ready = new Promise((resolve, reject) => {\n this._resolveReady = resolve;\n this._rejectReady = reject;\n });\n }\n\n async init(opts: {\n gl: HTMLCanvasElement;\n gridlines: HTMLCanvasElement;\n chrome: HTMLCanvasElement;\n facetConfig: FacetConfig;\n pluginConfig: PluginConfig;\n columnsConfig?: Record<string, any>;\n defaultChartType?: string;\n renderBlitMode: \"blit\" | \"direct\";\n }): Promise<void> {\n this._hostGlCanvas = opts.gl;\n const workerURL: string = await getWorkerURL();\n\n // Worker mode: bridge the worker's fresh `Client` (instantiated\n // in `bootstrapWorker` from `clientWasm` + `clientWorkerURL`)\n // back to the host's real `Client` via a `ProxySession` over a\n // dedicated `MessageChannel`.\n //\n // In-process mode skips this entirely \u2014 `bootstrapInProcess`\n // is handed the host's `Client` directly, so there's no\n // worker-side `Client` to bridge. The proxy port would just\n // dangle.\n if (RUNTIME_MODE === \"worker\") {\n this._proxyChannel = new MessageChannel();\n this._proxySession = (this._client as any).new_proxy_session(\n (bytes: Uint8Array) => {\n const buf = bytes.slice().buffer;\n this._proxyChannel!.port1.postMessage(buf, [buf]);\n },\n );\n\n this._proxyChannel.port1.addEventListener(\n \"message\",\n (e: MessageEvent) => {\n this._proxySession.handle_request(new Uint8Array(e.data));\n },\n );\n\n this._proxyChannel.port1.start();\n }\n\n // Blit mode keeps the visible `.webgl-canvas` main-thread with\n // a 2D context \u2014 the renderer paints into its own internal\n // `OffscreenCanvas` and ships each completed frame back as an\n // `ImageBitmap`. Direct mode transfers the visible canvas's\n // drawing buffer to the renderer so GL paints straight to\n // screen.\n // Blit mode also keeps the gridlines/chrome layers worker-side:\n // a transferred canvas presents on the compositor's schedule,\n // unsynchronized with the host's layout commits, so it can't\n // participate in the staged-present hold. The renderer\n // composites both layers into the shipped frame instead, and\n // the host-side placeholder canvases stay untouched\n // (transparent). Direct mode transfers all three surfaces.\n let glOC: OffscreenCanvas | undefined;\n let gridlinesOC: OffscreenCanvas | undefined;\n let chromeOC: OffscreenCanvas | undefined;\n if (opts.renderBlitMode === \"blit\") {\n this._displayCtx = opts.gl.getContext(\"2d\");\n } else {\n glOC = opts.gl.transferControlToOffscreen();\n gridlinesOC = opts.gridlines.transferControlToOffscreen();\n chromeOC = opts.chrome.transferControlToOffscreen();\n }\n\n const rect = opts.gl.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const themeVars = snapshotThemeVars(opts.gl);\n\n // Worker mode forwards `@font-face` rules so the worker's\n // separate `FontFaceSet` can resolve `ctx.font` family names.\n // In-process mode shares `document.fonts` with the host \u2014\n // omit the descriptors entirely.\n const fontFaces = RUNTIME_MODE === \"worker\" ? snapshotFontFaces() : [];\n const clientWasm =\n RUNTIME_MODE === \"worker\" ? this._clientWasm : undefined;\n\n const clientWorkerURL =\n RUNTIME_MODE === \"worker\" ? this._clientWorkerURL : undefined;\n\n const proxyPort =\n RUNTIME_MODE === \"worker\" ? this._proxyChannel!.port2 : undefined;\n\n const initMsg: InitMsg = {\n kind: \"init\",\n renderMode: opts.renderBlitMode,\n glCanvas: glOC,\n gridlinesCanvas: gridlinesOC,\n chromeCanvas: chromeOC,\n proxyPort,\n clientWorkerURL,\n clientWasm,\n chartTag: this._chartTag,\n viewName: this._view.__unsafe_get_name(),\n tableName: this._tableName,\n facetConfig: opts.facetConfig,\n pluginConfig: opts.pluginConfig,\n columnsConfig: opts.columnsConfig,\n defaultChartType: opts.defaultChartType,\n tileSource: TILE_SOURCES.specFor(\n opts.pluginConfig.map_tile_provider,\n ),\n themeVars,\n fontFaces,\n cssWidth: rect.width,\n cssHeight: rect.height,\n dpr,\n bufferMaxCapacity: 0,\n precompileShaders: this._precompileShaders,\n };\n\n this._lastPostedSize = {\n cssWidth: rect.width,\n cssHeight: rect.height,\n dpr,\n };\n this._handle = await this._createHandle(workerURL, initMsg);\n this._handle.addMessageListener((msg) =>\n this._handleRendererMsg(msg as WorkerMsg),\n );\n\n if (RUNTIME_MODE === \"worker\") {\n // Worker mode: the bootstrap is triggered by posting the\n // init message into the worker's scope (which the\n // `if (IS_WORKER_SCOPE)` block in `renderer.worker.ts`\n // listens for). All three canvases are omitted in blit mode\n // (the renderer allocates its own offscreens and ships\n // composited frames) \u2014 only include the transferred\n // surfaces present on this mode's init message.\n const transfer: Transferable[] = [this._proxyChannel!.port2];\n if (chromeOC) {\n transfer.unshift(chromeOC);\n }\n\n if (gridlinesOC) {\n transfer.unshift(gridlinesOC);\n }\n\n if (glOC) {\n transfer.unshift(glOC);\n }\n\n this._handle.post(initMsg, transfer);\n }\n\n // In-process mode: the handle's `_createHandle` already kicked\n // off `bootstrapInProcess` with the init msg directly, no\n // postMessage needed.\n\n await this._ready;\n }\n\n /**\n * Construct the underlying transport. Worker mode wraps the\n * module-shared `Worker` (lazy, page-singleton) and tags every\n * message with a unique `sessionId`. In-process mode pairs a\n * `MessageChannel` with a dynamically-imported\n * {@link bootstrapInProcess}.\n */\n private async _createHandle(\n workerURL: string,\n initMsg: InitMsg,\n ): Promise<RendererHandle> {\n if (RUNTIME_MODE === \"worker\") {\n const w = await getSharedWorker();\n const sessionId = ++NEXT_SESSION_ID;\n return {\n post: (msg, transfer) =>\n w.postMessage({ sessionId, msg }, transfer),\n addMessageListener: (cb) => {\n HOST_LISTENERS.set(sessionId, cb);\n },\n terminate: () => {\n HOST_LISTENERS.delete(sessionId);\n // Don't terminate the underlying worker \u2014 other\n // sessions may still be live. Worker-side\n // `WorkerRenderer` cleanup is driven by the\n // `destroy` ControlMsg posted by the transport\n // before reaching here.\n },\n };\n }\n\n // In-process: instantiate the renderer on this thread by\n // dynamic-importing the same module the worker uses. The Blob\n // URL (or file URL in debug builds) loads as ESM, so module\n // dedup means only one copy of the chart code lives in\n // memory regardless of how many host elements use this mode.\n // `@vite-ignore` is harmless under esbuild (esbuild's parser\n // ignores it); some downstream bundlers honor it to suppress\n // a static-import warning on the dynamic URL.\n //\n // Hand the host's already-bound `Client` to the renderer via\n // `bootstrapInProcess` \u2014 option B. The dynamically-imported\n // module has its own copy of the perspective-viewer\n // wasm-bindgen JS, but that copy stays unused: we never\n // construct `new Client(...)` inside it; we only ever call\n // methods on the host-supplied instance.\n const mod: any = await import(/* @vite-ignore */ workerURL);\n const channel = new MessageChannel();\n await mod.bootstrapInProcess({\n msg: initMsg,\n client: this._client,\n controlPort: channel.port2,\n });\n\n return {\n post: (msg, transfer) => channel.port1.postMessage(msg, transfer),\n addMessageListener: (cb) => {\n // `addEventListener(\"message\", \u2026)` does NOT auto-start\n // a `MessagePort` \u2014 only setting `onmessage` does.\n // Without this explicit `start()` the renderer's\n // `{ kind: \"ready\" }` would queue on `port1` forever\n // and `init()` would hang on `await this._ready`.\n channel.port1.addEventListener(\"message\", (e: MessageEvent) =>\n cb(e.data),\n );\n channel.port1.start();\n },\n terminate: () => {\n channel.port1.close();\n channel.port2.close();\n },\n };\n }\n\n setView(view: View): void {\n this._view = view;\n this._post({\n kind: \"setViewByName\",\n name: this._view.__unsafe_get_name(),\n });\n }\n\n setColumnsConfig(cfg: Record<string, any>): void {\n this._post({ kind: \"setColumnsConfig\", cfg });\n }\n\n setPluginConfig(cfg: PluginConfig): void {\n this._post({\n kind: \"setPluginConfig\",\n cfg,\n tileSource: TILE_SOURCES.specFor(cfg.map_tile_provider),\n });\n }\n\n setBufferMaxCapacity(n: number): void {\n this._post({ kind: \"setBufferMaxCapacity\", n });\n }\n\n /**\n * Trigger a worker-side data fetch + render cycle. The worker\n * resolves all schema / row-count metadata against its own `View`\n * and `Table`, runs `view.with_typed_arrays`, and pipes the\n * resulting `ColumnDataMap` directly into `chartImpl.uploadAndRender`\n * \u2014 no host-side `Client`/`Table`/`View` await, no `postMessage` of\n * column buffers.\n *\n * The returned promise resolves when the worker replies with\n * `loadAndRenderAck`. Per the worker's \"resolve on stale\"\n * contract, a mid-flight cancellation (a newer `loadAndRender`\n * superseding this one) still acks \u2014 the host's awaiter just\n * resolves quietly. Calls issued after `destroy()` resolve\n * immediately (see `_allocPending`).\n */\n loadAndRender(opts: {\n viewerConfig: {\n group_by: string[];\n split_by: string[];\n columns: (string | null)[];\n };\n options?: { float32?: boolean };\n }): Promise<void> {\n const { id, promise } = this._allocPending<void>(\"loadAndRender\");\n const msg: LoadAndRenderMsg = {\n kind: \"loadAndRender\",\n msgId: id,\n viewerConfig: opts.viewerConfig,\n options: { float32: opts.options?.float32 ?? true },\n };\n\n this._post(msg);\n return promise;\n }\n\n redraw(): void {\n this._post({ kind: \"redraw\" });\n }\n\n /**\n * Silently clear the worker chart's selection state (pinned tooltip) \u2014\n * no selection events are emitted; the worker echoes `dismissTooltip`\n * to drop the host-side pinned artifact. See `DeselectMsg`.\n */\n deselect(): void {\n this._post({ kind: \"deselect\" });\n }\n\n /**\n * Resize the chart to the GL canvas's CURRENT CSS box and resolve\n * once the resized frame has PRESENTED (the worker's `resizeAck`) \u2014\n * not at message-post, which would let callers proceed while the\n * old-dimensions bitmap is still on screen. Reactive geometry\n * changes only; anticipated ones go through {@link presize}.\n *\n * A measurement matching {@link _lastPostedSize} resolves immediately\n * WITHOUT a worker round trip: the worker has already rendered (or is\n * presenting) that exact frame, and re-posting would be a full\n * re-render of an identical bitmap.\n */\n resize(): Promise<void> {\n if (!this._hostGlCanvas) {\n return Promise.resolve();\n }\n\n const rect = this._hostGlCanvas.getBoundingClientRect();\n const dpr = window.devicePixelRatio || 1;\n const last = this._lastPostedSize;\n if (\n last &&\n Math.abs(last.cssWidth - rect.width) <= 0.5 &&\n Math.abs(last.cssHeight - rect.height) <= 0.5 &&\n last.dpr === dpr\n ) {\n return Promise.resolve();\n }\n\n return this._postResize(rect.width, rect.height);\n }\n\n /**\n * Staged-present variant of {@link resize}: render at the given\n * TARGET canvas CSS box (no measurement \u2014 the caller supplies the\n * box the pending layout commit will produce), HOLDING the\n * resulting frame (and any others that arrive meanwhile) offscreen\n * instead of blitting, so nothing on screen changes. Resolves,\n * once the resized frame is staged, to a present closure: calling\n * it blits the latest staged frame and exits the hold \u2014 the host\n * runs it in the same task as its layout commit so geometry and\n * pixels land in one paint. On rejection (teardown) the hold is\n * released here, so every settle path either frees the display or\n * hands the caller the release.\n */\n presize(cssWidth: number, cssHeight: number): Promise<(() => void) | void> {\n if (!this._hostGlCanvas) {\n return Promise.resolve();\n }\n\n const dpr = window.devicePixelRatio || 1;\n const last = this._lastPostedSize;\n if (\n last &&\n Math.abs(last.cssWidth - cssWidth) <= 0.5 &&\n Math.abs(last.cssHeight - cssHeight) <= 0.5 &&\n last.dpr === dpr\n ) {\n return Promise.resolve();\n }\n\n this._holdPresent = true;\n return this._postResize(cssWidth, cssHeight).then(\n () => () => this._presentStaged(),\n (err) => {\n this._presentStaged();\n throw err;\n },\n );\n }\n\n private _postResize(cssWidth: number, cssHeight: number): Promise<void> {\n const dpr = window.devicePixelRatio || 1;\n const { id, promise } = this._allocPending<void>(\"resize\");\n this._lastPostedSize = { cssWidth, cssHeight, dpr };\n this._post({\n kind: \"resize\",\n msgId: id,\n cssWidth,\n cssHeight,\n dpr,\n });\n return promise;\n }\n\n private _presentStaged(): void {\n this._holdPresent = false;\n const staged = this._stagedFrame;\n this._stagedFrame = null;\n if (staged) {\n this._drawFrameBitmap(staged);\n }\n }\n\n clear() {\n this._post({ kind: \"clear\" });\n }\n\n invalidateTheme() {\n if (!this._hostGlCanvas) {\n return;\n }\n\n const themeVars = snapshotThemeVars(this._hostGlCanvas);\n this._post({ kind: \"invalidateTheme\", themeVars });\n }\n\n async saveZoom() {\n const { id } = this._allocPending<any>(\"saveZoom\");\n this._post({ kind: \"saveZoom\", requestId: id });\n }\n\n /**\n * Allocate a pending request slot of the given `kind`. Returns the\n * id (encoded into the outgoing `ControlMsg`) and a promise that\n * resolves / rejects when the matching reply arrives or\n * `destroy()` drains the table. Requests issued *after* `destroy()`\n * settle immediately with the same per-kind semantics as the drain.\n */\n private _allocPending<T>(kind: PendingRenderType): {\n id: number;\n promise: Promise<T>;\n } {\n // A request issued after `destroy()` would never settle: `_post`\n // no-ops with no handle, so no reply ever lands \u2014 and the host\n // awaits `loadAndRender` while holding its per-renderer draw\n // lock, so a pending-forever promise wedges that panel's lock\n // permanently. (Reachable when an external DOM disconnect\n // `delete()`s the element mid-draw; the host's own teardown\n // paths are serialized behind the same lock.) Mirror the\n // `destroy()` drain: `loadAndRender` resolves silently,\n // reply-bearing kinds reject. The pre-attached no-op `catch`\n // marks the rejection handled for fire-and-forget callers\n // (`saveZoom`) without affecting real awaiters.\n if (this._destroyed) {\n if (kind === \"loadAndRender\") {\n return {\n id: -1,\n promise: Promise.resolve(undefined as unknown as T),\n };\n }\n\n const promise = Promise.reject<T>(\n new Error(\"RendererTransport destroyed\"),\n );\n promise.catch(() => {});\n return { id: -1, promise };\n }\n\n const id = ++this._pendingCounter;\n const promise = new Promise<T>((resolve, reject) => {\n this._pending.set(id, { kind, resolve, reject });\n });\n\n return { id, promise };\n }\n\n restoreZoom(state: any): void {\n this._post({ kind: \"restoreZoom\", state });\n }\n\n allZoomsDefault(): boolean {\n return this._allZoomsDefault;\n }\n\n resetAllZooms(): void {\n this._post({ kind: \"resetAllZooms\" });\n }\n\n resetExpandedDomain(): void {\n this._post({ kind: \"resetExpandedDomain\" });\n }\n\n /**\n * Request a PNG snapshot of the current frame. The worker flushes a\n * synchronous render across the GL + gridlines + chrome layers,\n * composites them into a single `OffscreenCanvas`, fills the theme\n * background, and replies with the `convertToBlob` result.\n */\n snapshotPng(): Promise<Blob> {\n const { id, promise } = this._allocPending<Blob>(\"snapshotPng\");\n this._post({ kind: \"snapshotPng\", requestId: id });\n return promise;\n }\n\n forwardInteraction(event: InteractionEvent): void {\n this._post({ kind: \"interaction\", event });\n }\n\n destroy(): void {\n this._destroyed = true;\n this._post({ kind: \"destroy\" });\n if (this._proxySession) {\n this._proxySession.close().catch(() => {});\n }\n\n if (this._proxyChannel) {\n this._proxyChannel.port1.close();\n this._proxyChannel = null;\n }\n\n if (this._handle) {\n this._handle.terminate();\n this._handle = null;\n }\n\n this._hostSink?.dismiss();\n this._hostSink = null;\n\n // The host's `<canvas>` elements are torn down by the plugin\n // element's `disconnectedCallback` after `destroy()` returns \u2014\n // null these refs now so any post-destroy code can't dereference\n // them, and so the GPU-backed 2D context can release earlier.\n this._hostGlCanvas = null;\n this._displayCtx = null;\n this._holdPresent = false;\n this._stagedFrame?.close();\n this._stagedFrame = null;\n\n // Drain pending request promises with kind-aware semantics:\n // - `loadAndRender` resolves silently (the host's awaited draw\n // observes a clean \"no more work\" rather than a teardown\n // rejection it would otherwise have to suppress).\n // - `saveZoom` / `snapshotPng` reject so the upstream promise\n // chain doesn't hang. Any unanswered messages still in the\n // worker's queue are abandoned along with the renderer when\n // the `destroy` ControlMsg fires worker-side.\n const teardownErr = new Error(\"RendererTransport destroyed\");\n for (const entry of this._pending.values()) {\n if (entry.kind === \"loadAndRender\") {\n entry.resolve(undefined);\n } else {\n entry.reject(teardownErr);\n }\n }\n\n this._pending.clear();\n }\n\n private _post(msg: ControlMsg): void {\n this._postRaw(msg, []);\n }\n\n private _postRaw(msg: ControlMsg, transfer: Transferable[]): void {\n if (!this._handle) {\n return;\n }\n\n this._handle.post(msg, transfer);\n }\n\n private _handleRendererMsg(msg: WorkerMsg): void {\n switch (msg.kind) {\n case \"ready\":\n this._resolveReady();\n break;\n case \"zoomChanged\":\n this._allZoomsDefault = msg.isDefault;\n this._onZoomChanged?.(msg.isDefault);\n break;\n case \"saveZoomReply\":\n this._resolvePending(msg.requestId, \"saveZoom\", msg.state);\n break;\n case \"pinTooltip\":\n this._ensureHostSink()?.pin(\n msg.grid,\n msg.pos,\n msg.bounds,\n msg.style,\n );\n break;\n case \"dismissTooltip\":\n this._hostSink?.dismiss();\n break;\n case \"setCursor\":\n this._ensureHostSink()?.setCursor(msg.cursor);\n break;\n case \"pluginConfigDelta\":\n this._onPluginConfigDelta?.(msg.fields);\n break;\n case \"userClick\":\n this._dispatchOnViewer(\n new CustomEvent<PerspectiveClickDetail>(\n \"perspective-click\",\n {\n bubbles: true,\n composed: true,\n // Tag with the source panel so a multi-panel host\n // can attribute the click to the right panel.\n detail: { ...msg.detail, panel: this._panel },\n },\n ),\n );\n break;\n case \"userSelect\": {\n const removeConfigs = this._lastInsertConfig\n ? [this._lastInsertConfig]\n : [];\n const insertConfigs = msg.selected ? [msg.insertConfig] : [];\n this._lastInsertConfig = msg.selected\n ? msg.insertConfig\n : undefined;\n const detail = new PerspectiveSelectDetail(\n msg.selected,\n msg.row,\n msg.column_names,\n // `Partial<ViewConfig>` (what the chart emits) is\n // structurally a `ViewConfigUpdate` for the\n // `filter`-only patches we ship; the only\n // incompatible field (`group_by_depth: number |\n // null`) is never set by our emitters.\n removeConfigs as any,\n insertConfigs as any,\n );\n // Tag with the source panel so the host's master/detail +\n // global-filter routing can identify the originating panel.\n detail.panel = this._panel;\n this._dispatchOnViewer(\n new CustomEvent<PerspectiveSelectDetail>(\n \"perspective-global-filter\",\n {\n bubbles: true,\n composed: true,\n detail,\n },\n ),\n );\n break;\n }\n\n case \"frameBitmap\":\n if (this._holdPresent) {\n this._stagedFrame?.close();\n this._stagedFrame = msg.bitmap;\n } else {\n this._drawFrameBitmap(msg.bitmap);\n }\n\n break;\n case \"error\":\n this._rejectReady(new Error(msg.message));\n break;\n case \"loadAndRenderAck\":\n if (msg.error !== undefined) {\n this._rejectPending(\n msg.msgId,\n \"loadAndRender\",\n new Error(msg.error),\n );\n } else {\n this._resolvePending(msg.msgId, \"loadAndRender\", undefined);\n }\n\n break;\n case \"resizeAck\":\n this._resolvePending(msg.msgId, \"resize\", undefined);\n break;\n case \"snapshotPngReply\":\n if (msg.error !== undefined) {\n this._rejectPending(\n msg.requestId,\n \"snapshotPng\",\n new Error(msg.error),\n );\n } else {\n this._resolvePending(\n msg.requestId,\n \"snapshotPng\",\n msg.blob,\n );\n }\n\n break;\n }\n }\n\n /**\n * Look up a pending request by id, verify the recorded kind\n * matches the inbound reply, resolve, and remove. Mismatches are\n * silently dropped \u2014 they would only fire if the worker echoed\n * the wrong kind for a given id, which would itself be a bug\n * worth catching at the worker side.\n */\n private _resolvePending(\n id: number,\n kind: PendingRenderType,\n value: unknown,\n ): void {\n const entry = this._pending.get(id);\n if (!entry || entry.kind !== kind) {\n return;\n }\n\n this._pending.delete(id);\n entry.resolve(value);\n }\n\n private _rejectPending(\n id: number,\n kind: PendingRenderType,\n error: Error,\n ): void {\n const entry = this._pending.get(id);\n if (!entry || entry.kind !== kind) {\n return;\n }\n\n this._pending.delete(id);\n entry.reject(error);\n }\n\n /**\n * Blit-mode handler: draw a renderer-emitted frame into the\n * visible 2D-context display canvas, then close the bitmap so its\n * GPU-backed surface is released. Resizes the visible canvas's\n * drawing buffer to the bitmap dimensions on first frame and\n * after any worker-side resize \u2014 the host doesn't directly\n * control GL canvas size in blit mode, so we follow whatever the\n * renderer emits.\n */\n private _drawFrameBitmap(bitmap: ImageBitmap): void {\n if (this._displayCtx && this._hostGlCanvas) {\n const w = bitmap.width;\n const h = bitmap.height;\n if (this._hostGlCanvas.width !== w) {\n this._hostGlCanvas.width = w;\n }\n\n if (this._hostGlCanvas.height !== h) {\n this._hostGlCanvas.height = h;\n }\n\n this._displayCtx.globalCompositeOperation = \"copy\";\n this._displayCtx.drawImage(bitmap, 0, 0);\n }\n\n bitmap.close();\n }\n\n /**\n * Dispatch a `CustomEvent` on the `<perspective-viewer>` ancestor\n * of this transport's GL canvas. Walks the parent chain so the\n * event bubbles from the viewer (matching where datagrid\n * dispatches its `perspective-click` / `perspective-global-filter`\n * events). No-op when the canvas is detached or no viewer ancestor\n * exists (test harnesses, snapshot mode).\n */\n private _dispatchOnViewer(ev: CustomEvent): void {\n if (!this._hostGlCanvas) {\n return;\n }\n\n let node: Node | null = this._hostGlCanvas;\n while (node) {\n if (\n node instanceof HTMLElement &&\n node.tagName === \"PERSPECTIVE-VIEWER\"\n ) {\n node.dispatchEvent(ev);\n return;\n }\n\n // Cross shadow-root boundaries \u2014 `parentNode` returns `null`\n // at a ShadowRoot, so use `host` when present.\n node =\n (node as ShadowRoot).host ??\n (node as Element).parentNode ??\n null;\n }\n }\n\n /**\n * Lazily construct a `DomHostSink` rooted at the host GL canvas\n * (cursor mutations) and its parent (pinned-tooltip `<div>`).\n * Returns `null` if the canvas has been detached.\n */\n private _ensureHostSink(): DomHostSink | null {\n if (this._hostSink) {\n return this._hostSink;\n }\n\n const parent = this._hostGlCanvas?.parentElement;\n if (!parent || !this._hostGlCanvas) {\n return null;\n }\n\n this._hostSink = new DomHostSink(this._hostGlCanvas, parent);\n return this._hostSink;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { parseCSSColorToVec3 } from \"../utils/css\";\nimport { parseCssGradient, type GradientStop } from \"./gradient\";\n\nexport type { GradientStop } from \"./gradient\";\n\nfunction clampOpacity(v: number): number {\n if (!isFinite(v)) {\n return 0.5;\n }\n\n if (v < 0) {\n return 0;\n }\n\n if (v > 1) {\n return 1;\n }\n\n return v;\n}\n\nfunction clampGap(v: number): number {\n if (!isFinite(v) || v < 0) {\n return 1;\n }\n\n return v;\n}\n\nexport interface Theme {\n fontFamily: string;\n tickColor: string;\n labelColor: string;\n axisLineColor: string;\n gridlineColor: string;\n backgroundColor: string;\n gradientStops: GradientStop[];\n legendText: string;\n legendBorder: string;\n tooltipBg: string;\n tooltipText: string;\n tooltipBorder: string;\n\n /**\n * Fill opacity for area glyphs. `--psp-charts--area--opacity`.\n */\n areaOpacity: number;\n\n /**\n * Pixel gap between heatmap cells. Controls the inset applied in the\n * heatmap vertex shader so neighbouring cells remain visually\n * distinguishable. `--psp-charts--heatmap-gap--px`.\n */\n heatmapGapPx: number;\n\n /**\n * Pixel gap between sunburst arcs (both radial \u2014 between ring\n * levels \u2014 and angular \u2014 between siblings). Works the same way as\n * `heatmapGapPx`: a symmetric inset in the vertex shader so the\n * transparent background shows through as a border.\n * `--psp-charts--sunburst-gap--px`.\n */\n sunburstGapPx: number;\n\n /**\n * Discrete series palette read from `--psp-charts--series-N--color`\n * (N = 1, 2, \u2026). Empty when no palette is defined \u2014 callers should\n * fall back to `gradientStops` sampling in that case.\n */\n seriesPalette: [number, number, number][];\n}\n\n/**\n * Plain map of CSS variable name \u2192 resolved value. Produced on the\n * main thread via `snapshotThemeVars` and shipped to the worker\n * Renderer (which has no DOM and can't call `getComputedStyle`).\n */\nexport type ThemeSnapshot = Record<string, string>;\n\n/**\n * Decode a `ThemeSnapshot` into the parsed `Theme` the renderer\n * consumes. Workers reach this from a serialized snapshot; host code\n * snapshots from the live DOM via `theme-snapshot.ts` and feeds it\n * through here.\n */\nexport function resolveThemeFromVars(vars: ThemeSnapshot): Theme {\n const get = (prop: string, fallback: string): string =>\n vars[prop] || fallback;\n\n const gradientSrc =\n vars[\"--psp-charts--gradient--background\"] ||\n vars[\"--psp-charts--full-gradient--background\"] ||\n \"linear-gradient(#0366d6 0%, #ff7f0e 100%)\";\n\n const gradientStops = parseCssGradient(gradientSrc);\n const seriesPalette: [number, number, number][] = [];\n for (let i = 1; ; i++) {\n const raw = vars[`--psp-charts--series-${i}--color`];\n if (!raw) {\n break;\n }\n\n seriesPalette.push(parseCSSColorToVec3(raw));\n }\n\n return {\n fontFamily: get(\n \"--psp-charts--font-family\",\n get(\"font-family\", \"monospace\"),\n ),\n backgroundColor: get(\n \"--psp--background-color\",\n \"rgba(255, 255, 255, 1)\",\n ),\n tickColor: get(\n \"--psp-charts--axis-ticks--color\",\n \"rgba(160, 0, 0, 0.8)\",\n ),\n labelColor: get(\"--psp--color\", \"rgba(180, 0, 0, 0.9)\"),\n axisLineColor: get(\n \"--psp-charts--axis-lines--color\",\n \"rgba(160, 0, 0, 0.4)\",\n ),\n gridlineColor: get(\n \"--psp-charts--gridline--color\",\n \"rgba(255, 0, 0, 1)\",\n ),\n gradientStops,\n legendText: get(\n \"--psp-charts--legend--color\",\n \"rgba(180, 180, 180, 0.9)\",\n ),\n legendBorder: get(\n \"--psp-charts--legend-border--color\",\n \"rgba(128,128,128,0.3)\",\n ),\n tooltipBg: get(\n \"--psp-charts--tooltip--background\",\n \"rgba(155,155,155,0.8)\",\n ),\n tooltipText: get(\"--psp-charts--tooltip--color\", \"#161616\"),\n tooltipBorder: get(\"--psp-charts--tooltip--border-color\", \"#fff\"),\n areaOpacity: clampOpacity(\n parseFloat(get(\"--psp-charts--area--opacity\", \"0.85\")),\n ),\n heatmapGapPx: clampGap(\n parseFloat(get(\"--psp-charts--heatmap-gap--px\", \"0\")),\n ),\n sunburstGapPx: clampGap(\n parseFloat(get(\"--psp-charts--sunburst-gap--px\", \"1\")),\n ),\n seriesPalette,\n };\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { sampleGradient, type GradientStop } from \"./gradient\";\n\nexport type Vec3 = [number, number, number];\n\n/**\n * Build a series palette of length `count` by sampling the theme gradient\n * at evenly-spaced offsets. For count == 1 returns the 50% stop.\n */\nfunction interpolatePalette(stops: GradientStop[], count: number): Vec3[] {\n if (count <= 0) {\n return [];\n }\n\n const out: Vec3[] = new Array(count);\n for (let i = 0; i < count; i++) {\n const t = count === 1 ? 0.5 : i / (count - 1);\n const c = sampleGradient(stops, t);\n out[i] = [c[0], c[1], c[2]];\n }\n\n return out;\n}\n\n/**\n * Resolve a series palette: use the discrete `--psp-charts--series-N--color`\n * palette when available, otherwise fall back to evenly-spaced samples of\n * the theme gradient.\n */\nexport function resolvePalette(\n discrete: Vec3[],\n stops: GradientStop[],\n count: number,\n): Vec3[] {\n if (discrete.length > 0) {\n if (discrete.length >= count) {\n return discrete.slice(0, count);\n }\n\n // Cycle through the discrete palette for overflow indices.\n const out: Vec3[] = new Array(count);\n for (let i = 0; i < count; i++) {\n out[i] = discrete[i % discrete.length];\n }\n\n return out;\n }\n\n return interpolatePalette(stops, count);\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport { colorsToCss, stopsToCss } from \"../theme/gradient\";\nimport type { View } from \"@perspective-dev/client\";\nimport type {\n HTMLPerspectiveViewerElement,\n IPerspectiveViewerPlugin,\n PluginStaticConfig,\n} from \"@perspective-dev/viewer\";\nimport {\n ChartTypeConfig,\n LEGEND_FIELDS,\n TOOLTIP_FIELDS,\n PluginConfigField,\n} from \"./charts\";\nimport style from \"../../css/perspective-viewer-charts.css\";\nimport {\n DEFAULT_FACET_CONFIG,\n DEFAULT_PLUGIN_CONFIG,\n type FacetConfig,\n type PluginConfig,\n} from \"../charts/chart\";\nimport {\n CHART_DATE_DEFAULTS,\n CHART_DATETIME_DEFAULTS,\n CHART_NUMBER_DEFAULTS,\n} from \"./format-defaults\";\nimport { RawEventForwarder } from \"../interaction/raw-event-forwarder\";\nimport { RendererTransport } from \"../transport/renderer-transport\";\nimport { TILE_SOURCES, type TileSourceSpec } from \"../map/tile-source\";\nimport { RENDER_BLIT_MODE } from \"../config\";\nimport { snapshotThemeVars } from \"../theme/theme-snapshot\";\nimport { resolveThemeFromVars, type Theme } from \"../theme/theme\";\nimport { resolvePalette } from \"../theme/palette\";\nimport { vec3ToHexColor } from \"../utils/css\";\n\n/**\n * Facet-rendering defaults shared by every chart. Per-chart overrides\n * arrive through `plugin_config` (`facet_mode` + `facet_zoom_mode`);\n * the remaining fields (`shared_x_axis`, `shared_y_axis`,\n * `coordinated_tooltip`, `facet_padding`) are not yet user-configurable\n * \u2014 flip the defaults in `DEFAULT_FACET_CONFIG` to change globally.\n */\nconst FACET_CONFIG_DEFAULTS: FacetConfig = { ...DEFAULT_FACET_CONFIG };\n\n/**\n * Register a raster XYZ tile provider at runtime. The provider joins\n * the bundled [map/tile-sources.json] entries in the settings panel's\n * `map_tile_provider` enum and resolves on any map chart from its next\n * config forward onward \u2014 the resolved spec rides every outgoing\n * `setPluginConfig` / `init` message alongside the config that names\n * it, so no separate registry-sync operation exists. Re-registering an\n * id replaces it (a changed template drops cached tiles via the\n * content-derived cache identity); a chart currently displaying that\n * id picks the replacement up on its next `restore()`. Throws\n * `TypeError` on a malformed spec. Returns the normalized spec.\n *\n * A key-gated provider is registered with the key embedded in its\n * `template` \u2014 keys never enter `plugin_config`, so they never appear\n * in `save()` output.\n */\nexport function registerTileSource(spec: unknown): TileSourceSpec {\n return TILE_SOURCES.register(spec);\n}\n\n/**\n * Static UI-control spec per `plugin_config` field. Mirrors the shape\n * `column_config_schema` already returns (datagrid). The runtime default\n * is sourced separately from the chart-type-effective defaults at\n * `fieldSpec` call time so per-chart overrides like\n * `include_zero=true` for Y Bar / Y Area / X Bar surface in the UI.\n */\ntype FieldSpec =\n | { kind: \"Bool\" }\n | {\n kind: \"Enum\";\n variants: ReadonlyArray<{ value: string; label: string }>;\n }\n | { kind: \"Number\"; min: number; max: number; step?: number };\n\n/**\n * A `FieldSpec` entry may be a thunk when its contents depend on\n * runtime state \u2014 `map_tile_provider`'s variants come from the tile-\n * source registry, which grows via `registerTileSource`, so the enum\n * must be resolved per `plugin_config_schema()` call rather than at\n * module init.\n */\nconst FIELD_SCHEMAS: Record<PluginConfigField, FieldSpec | (() => FieldSpec)> =\n {\n auto_alt_y_axis: { kind: \"Bool\" },\n include_zero: { kind: \"Bool\" },\n domain_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"fit\", label: \"Fit\" },\n { value: \"expand\", label: \"Expand\" },\n ],\n },\n facet_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"grid\", label: \"Grid\" },\n { value: \"overlay\", label: \"Overlay\" },\n ],\n },\n facet_zoom_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"shared\", label: \"Shared\" },\n { value: \"independent\", label: \"Independent\" },\n ],\n },\n series_zoom_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"dynamic\", label: \"Dynamic\" },\n { value: \"fixed\", label: \"Fixed\" },\n ],\n },\n line_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 16 },\n point_size_px: { kind: \"Number\", min: 1, max: 32 },\n band_inner_frac: { kind: \"Number\", min: 0.1, max: 1, step: 0.01 },\n bar_inner_pad: { kind: \"Number\", min: 0, max: 0.9, step: 0.01 },\n wick_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 8 },\n ohlc_line_width_px: { kind: \"Number\", min: 0.5, step: 0.5, max: 8 },\n gradient_radius_px: { kind: \"Number\", min: 2, step: 1, max: 256 },\n gradient_intensity: { kind: \"Number\", min: 0.05, step: 0.05, max: 4 },\n gradient_heat_max: { kind: \"Number\", min: 0.1, step: 0.1, max: 64 },\n gradient_color_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"mean\", label: \"Mean (density-weighted)\" },\n { value: \"density\", label: \"Density only\" },\n { value: \"extreme\", label: \"Extremes\" },\n { value: \"signed\", label: \"Signed sum\" },\n ],\n },\n map_tile_provider: () => ({\n kind: \"Enum\",\n variants: TILE_SOURCES.list().map((s) => ({\n value: s.id,\n label: s.label,\n })),\n }),\n map_tile_alpha: { kind: \"Number\", min: 0, max: 1, step: 0.05 },\n numeric_axes: { kind: \"Bool\" },\n legend_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"auto\", label: \"Auto\" },\n { value: \"sidebar\", label: \"Sidebar\" },\n { value: \"none\", label: \"None\" },\n { value: \"floating\", label: \"Floating\" },\n ],\n },\n legend_size_mode: {\n kind: \"Enum\",\n variants: [\n { value: \"auto\", label: \"Auto\" },\n { value: \"fixed\", label: \"Fixed\" },\n ],\n },\n // 0 = auto (the chart family's historical gutter width).\n legend_width_px: { kind: \"Number\", min: 0, max: 512, step: 1 },\n legend_height_px: { kind: \"Number\", min: 48, max: 1024, step: 1 },\n legend_anchor: {\n kind: \"Enum\",\n variants: [\n { value: \"top-right\", label: \"Top Right\" },\n { value: \"top-left\", label: \"Top Left\" },\n { value: \"bottom-right\", label: \"Bottom Right\" },\n { value: \"bottom-left\", label: \"Bottom Left\" },\n ],\n },\n legend_x: { kind: \"Number\", min: 0, max: 1, step: 0.01 },\n legend_y: { kind: \"Number\", min: 0, max: 1, step: 0.01 },\n legend_opacity: { kind: \"Number\", min: 0, max: 1, step: 0.05 },\n tooltip_max_column_px: { kind: \"Number\", min: 40, max: 512, step: 1 },\n tooltip_opacity: { kind: \"Number\", min: 0, max: 1, step: 0.05 },\n };\n\nfunction fieldSpec(\n key: PluginConfigField,\n defaults: PluginConfig,\n): Record<string, unknown> & { kind: string } {\n const entry = FIELD_SCHEMAS[key];\n const spec = typeof entry === \"function\" ? entry() : entry;\n return { ...spec, key, default: defaults[key] };\n}\n\nconst PLUGIN_FIELD_GROUPS: ReadonlyArray<{\n key: string;\n fields: readonly PluginConfigField[];\n}> = [\n {\n key: \"axes\",\n fields: [\n \"auto_alt_y_axis\",\n \"include_zero\",\n \"domain_mode\",\n \"numeric_axes\",\n ],\n },\n {\n key: \"facets\",\n fields: [\"facet_mode\", \"facet_zoom_mode\", \"series_zoom_mode\"],\n },\n {\n key: \"glyph\",\n fields: [\n \"line_width_px\",\n \"point_size_px\",\n \"band_inner_frac\",\n \"bar_inner_pad\",\n \"wick_width_px\",\n \"ohlc_line_width_px\",\n ],\n },\n {\n key: \"density\",\n fields: [\n \"gradient_color_mode\",\n \"gradient_radius_px\",\n \"gradient_intensity\",\n \"gradient_heat_max\",\n ],\n },\n { key: \"basemap\", fields: [\"map_tile_provider\", \"map_tile_alpha\"] },\n { key: \"legend\", fields: LEGEND_FIELDS },\n { key: \"tooltip\", fields: TOOLTIP_FIELDS },\n];\n\nconst GLOBAL_STYLES = (() => {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(style);\n return [sheet];\n})();\n\n/**\n * Process-global GL presentation strategy, shared by *every* chart-type\n * plugin in this renderer. Seeded from the build-time {@link RENDER_BLIT_MODE}\n * and overridable at runtime via\n * {@link HTMLPerspectiveViewerWebGLPluginElement.setBlitMode}.\n *\n * Module scope (not per-instance) on purpose: blit-vs-direct is a\n * whole-renderer decision \u2014 in `\"blit\"` mode the worker shares a pool of\n * GL contexts across all charts ([webgl/context-pool.ts]), so a page\n * can't sensibly mix strategies per chart. Every per-chart-type subclass\n * registered in [index.ts] reads this one value when it builds its\n * renderer, so setting it once (before the first chart renders) applies\n * to all of them.\n */\nlet BLIT_MODE: \"direct\" | \"blit\" = RENDER_BLIT_MODE;\n\nexport class HTMLPerspectiveViewerWebGLPluginElement\n extends HTMLElement\n implements IPerspectiveViewerPlugin\n{\n declare _chartType: ChartTypeConfig;\n\n private _initialized = false;\n private _glCanvas!: HTMLCanvasElement;\n private _gridlineCanvas!: HTMLCanvasElement;\n private _chromeCanvas!: HTMLCanvasElement;\n private _renderer: RendererTransport | null = null;\n private _rendererPromise: Promise<RendererTransport> | null = null;\n private _rawEventForwarder: RawEventForwarder | null = null;\n private _resetClickAbort: AbortController | null = null;\n\n /**\n * Plugin-scoped global config. Seeded lazily from\n * `_effectiveDefaults()` (which folds\n * `_chartType.plugin_field_defaults` over `DEFAULT_PLUGIN_CONFIG`)\n * because base-class field initializers run before the subclass\n * `_chartType` assignment. `restore({ plugin_config })` merges\n * incoming values on top of the same effective defaults so fields\n * the host omits fall back to the chart-type default\n * (`include_zero = true` for Y Bar / Y Area / X Bar, `false`\n * elsewhere). Held on the element (not just inside the worker) so\n * a `_buildRenderer` triggered after a `restore` ships the\n * resolved values in the `InitMsg`.\n */\n private _pluginConfigStore: PluginConfig | null = null;\n\n /**\n * Per-column config (`alt_axis`, `chart_type`, formats, \u2026), held on\n * the element for the same reason as `_pluginConfigStore`: the host\n * calls `restore()` BEFORE the first draw builds the renderer, so\n * forwarding only to a live renderer silently drops the initial\n * `columns_config` \u2014 `_buildRenderer` ships it in the `InitMsg`\n * instead.\n */\n private _columnsConfig: Record<string, any> = {};\n\n private get _pluginConfig(): PluginConfig {\n if (!this._pluginConfigStore) {\n this._pluginConfigStore = this._effectiveDefaults();\n }\n\n return this._pluginConfigStore;\n }\n\n private set _pluginConfig(value: PluginConfig) {\n this._pluginConfigStore = value;\n }\n\n private _effectiveDefaults(): PluginConfig {\n return {\n ...DEFAULT_PLUGIN_CONFIG,\n ...(this._chartType.plugin_field_defaults ?? {}),\n };\n }\n\n connectedCallback() {\n if (!this._initialized) {\n this.attachShadow({ mode: \"open\" });\n for (const sheet of GLOBAL_STYLES) {\n this.shadowRoot!.adoptedStyleSheets.push(sheet);\n }\n\n this.shadowRoot!.innerHTML =\n `<div class=\"webgl-container\">` +\n `<div class=\"zoom-controls\">` +\n `<button class=\"zoom-reset\">Reset Zoom</button>` +\n `</div>` +\n `</div>`;\n\n this._initialized = true;\n }\n\n if (!this._glCanvas?.isConnected) {\n this._buildCanvasStack();\n }\n }\n\n private _buildCanvasStack(): void {\n const container = this.shadowRoot!.querySelector(\".webgl-container\")!;\n container.insertAdjacentHTML(\n \"afterbegin\",\n `<canvas class=\"webgl-gridlines\"></canvas>` +\n `<canvas class=\"webgl-canvas\"></canvas>` +\n `<canvas class=\"webgl-chrome\"></canvas>`,\n );\n\n this._glCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-canvas\")!;\n this._gridlineCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-gridlines\")!;\n this._chromeCanvas =\n container.querySelector<HTMLCanvasElement>(\".webgl-chrome\")!;\n }\n\n private _clearCanvasStack(): void {\n const container = this.shadowRoot?.querySelector(\".webgl-container\");\n if (container) {\n for (const c of Array.from(container.querySelectorAll(\"canvas\"))) {\n c.remove();\n }\n }\n\n this._glCanvas = null!;\n this._gridlineCanvas = null!;\n this._chromeCanvas = null!;\n }\n\n /**\n * Fires when the host (`<perspective-viewer>`) removes this plugin\n * from the DOM on chart-type switch \u2014 see\n * `renderer/activate.rs::remove_inactive_plugin`. Without this,\n * inactive plugin instances retain their `RendererTransport`\n * (worker + WebGL context + compiled shader programs) until the\n * entire viewer is torn down, so a user cycling all 12 chart kinds\n * holds 12 GL contexts per viewer and routinely exceeds the\n * browser's per-page context cap (~16) in workspaces.\n */\n disconnectedCallback() {\n this.delete();\n this._clearCanvasStack();\n }\n\n /**\n * Lazy renderer construction. Memoizes the in-flight `init()`\n * promise so concurrent `draw()` calls during async setup await\n * the same initialization rather than racing.\n */\n private _ensureRenderer(view: View): Promise<RendererTransport> {\n if (!this._initialized) {\n this.connectedCallback();\n }\n\n if (this._rendererPromise) {\n return this._rendererPromise;\n }\n\n // `_buildRenderer` is async \u2014 it awaits `getClient`, `getTable`,\n // and a full worker handshake \u2014 so a `disconnectedCallback`\n // (toggle / chart-type switch) frequently lands *before* this\n // `.then` runs. At that point `this._renderer` is still null,\n // so `delete()`'s `if (this._renderer)` teardown is skipped and\n // the freshly-built transport (and its WebGL context) would be\n // assigned to a detached element and leak \u2014 one context per\n // raced toggle, until the browser evicts the oldest.\n //\n // `delete()` sets `_rendererPromise = null`, so promise identity\n // is the dispose signal: if `this._rendererPromise` no longer\n // points at *this* build when it resolves, the element was\n // deleted (or a reconnect started a newer build) and we destroy\n // the orphan instead of adopting it. Promise identity is the\n // right token: a rapid draw\u2192update must NOT tear down the\n // single in-flight build it shares via this memoized promise.\n const p: Promise<RendererTransport> = this._buildRenderer(view).then(\n (r) => {\n if (this._rendererPromise !== p) {\n r.destroy();\n throw new Error(\"renderer disposed during init\");\n }\n\n this._renderer = r;\n this._setupInteraction(r);\n return r;\n },\n );\n\n // Swallow the dispose rejection so it doesn't surface as an\n // unhandled rejection; `_drawImpl` catches it and bails.\n p.catch(() => {});\n this._rendererPromise = p;\n return p;\n }\n\n /**\n * Capture raw DOM events on the GL canvas with `RawEventForwarder`\n * and post them over the control channel. The renderer dispatches\n * them through its own resolver + `applyWheel` / `applyPan` for\n * zoom/pan, and through `TooltipController` virtual dispatch for\n * hover/click; `zoomChanged` updates push back so the reset-zoom\n * button visibility tracks the renderer-side state.\n *\n * The `zoomChanged` callback was wired at `RendererTransport`\n * construction time; here we just attach the event forwarder and\n * the reset-button click handler.\n */\n private _setupInteraction(renderer: RendererTransport): void {\n if (this._rawEventForwarder) {\n return;\n }\n\n const zoomControls = this.shadowRoot!.querySelector(\n \".zoom-controls\",\n ) as HTMLDivElement | null;\n\n this._rawEventForwarder = new RawEventForwarder();\n this._rawEventForwarder.attach(this._glCanvas, (event) => {\n renderer.forwardInteraction(event);\n });\n\n const resetBtn = this.shadowRoot!.querySelector(\".zoom-reset\");\n if (resetBtn) {\n this._resetClickAbort = new AbortController();\n resetBtn.addEventListener(\n \"click\",\n () => {\n renderer.resetAllZooms();\n if (zoomControls) {\n zoomControls.classList.remove(\"visible\");\n }\n },\n { signal: this._resetClickAbort.signal },\n );\n }\n }\n\n private async _buildRenderer(view: View): Promise<RendererTransport> {\n const viewer = this.parentElement as HTMLPerspectiveViewerElement;\n // This chart's own panel (its `slot`). Used to scope the client/table\n // to THIS panel rather than the host's active/seed panel (the bare\n // getClient()/getTable() resolve element-wide in a multi-panel viewer),\n // and to tag the dispatched interaction events with their source panel.\n const panel = this.getAttribute(\"slot\") ?? undefined;\n const client = await viewer.getClient({ panel });\n const viewer_class = customElements.get(\"perspective-viewer\");\n const clientWasm = viewer_class.get_wasm_module();\n const clientWorkerURL = viewer_class.get_worker_url();\n const table = await viewer?.getTable?.({ panel });\n const tableName: string | undefined = table\n ? await table.get_name()\n : undefined;\n\n const zoomControls = this.shadowRoot!.querySelector(\n \".zoom-controls\",\n ) as HTMLDivElement | null;\n\n const transport = new RendererTransport({\n client,\n view,\n tableName,\n panel,\n clientWorkerURL,\n clientWasm,\n chartTag: this._chartType.tag,\n maxCells: this._chartType.max_cells,\n precompileShaders: true,\n onZoomChanged: (isDefault: boolean) => {\n if (zoomControls) {\n zoomControls.classList.toggle(\"visible\", !isDefault);\n }\n },\n onPluginConfigDelta: (fields) => {\n this._pluginConfig = { ...this._pluginConfig, ...fields };\n const host = this\n .parentElement as HTMLPerspectiveViewerElement | null;\n (\n host?.restore(\n { plugin_config: fields },\n panel ? { panel } : undefined,\n ) as Promise<void> | undefined\n )?.catch((e: unknown) => {\n console.error(\"legend config persistence failed\", e);\n });\n },\n });\n\n await transport.init({\n gl: this._glCanvas,\n gridlines: this._gridlineCanvas,\n chrome: this._chromeCanvas,\n facetConfig: {\n ...FACET_CONFIG_DEFAULTS,\n facet_mode: this._pluginConfig.facet_mode,\n zoom_mode: this._pluginConfig.facet_zoom_mode,\n },\n pluginConfig: this._pluginConfig,\n columnsConfig: this._columnsConfig,\n defaultChartType: this._chartType.default_chart_type,\n renderBlitMode: BLIT_MODE,\n });\n\n return transport;\n }\n\n /**\n * Select the GL presentation strategy for *all* chart-type plugins\n * in this renderer. Static + process-global: the value is shared by\n * every per-chart-type subclass, so it must be set once before the\n * charts that should use it build their renderers (a renderer reads\n * {@link BLIT_MODE} at construction in `_buildRenderer`; charts\n * already built keep their mode until torn down and rebuilt).\n *\n * - `\"direct\"` \u2014 each chart owns a GL context 1:1 with its visible\n * canvas (lowest latency; bounded by the browser's ~16-context\n * cap).\n * - `\"blit\"` \u2014 charts render off-screen and share a pool of GL\n * contexts ([webgl/context-pool.ts]), so a page can exceed the cap.\n */\n static setBlitMode(mode: \"direct\" | \"blit\") {\n BLIT_MODE = mode;\n }\n\n static registerTileSource(spec: unknown): TileSourceSpec {\n return registerTileSource(spec);\n }\n\n static tileSources(): readonly TileSourceSpec[] {\n return TILE_SOURCES.list();\n }\n\n get_static_config(): PluginStaticConfig {\n return {\n name: this._chartType.name,\n category: this._chartType.category,\n select_mode: this._chartType.selectMode,\n min_config_columns: this._chartType.initial.count,\n config_column_names: this._chartType.initial.names,\n max_cells: this._chartType.max_cells,\n max_columns: this._chartType.max_columns,\n group_rollup_modes: [\"flat\"],\n split_rollup_modes: [\"flat\"],\n group_by_role: this._chartType.group_by_role,\n split_by_role: this._chartType.split_by_role,\n connects_row_order: !!this._chartType.connects_row_order,\n priority: 0,\n can_render_column_styles:\n !!this._chartType.default_chart_type ||\n this._chartType.category === \"Cartesian Charts\" ||\n this._chartType.category === \"Hierarchical Charts\" ||\n this._chartType.category === \"Map Charts\",\n };\n }\n\n column_config_schema(\n column_type: string,\n group: string | undefined,\n column_name: string,\n current_value: Record<string, unknown> | null,\n viewer_config?: {\n columns?: (string | null)[];\n group_by?: string[];\n split_by?: string[];\n group_rollup_mode?: string;\n },\n ) {\n const fields: Array<Record<string, unknown> & { kind: string }> = [];\n\n if (group === \"Color\") {\n const numeric_gradient =\n this._chartType.category === \"Hierarchical Charts\"\n ? column_type === \"integer\" ||\n column_type === \"float\" ||\n column_type === \"date\" ||\n column_type === \"datetime\"\n : column_type !== \"string\";\n if (numeric_gradient) {\n fields.push({\n kind: \"GradientStops\",\n key: \"gradient\",\n default: this._themeGradientStopsSpec(),\n });\n } else {\n fields.push({\n kind: \"Palette\",\n key: \"palette\",\n default: this._themeSeriesPaletteHex(),\n });\n }\n }\n\n // Y-series plugins expose the per-column chart_type picker; non-Y\n // plugins leave `default_chart_type` unset.\n const def = this._chartType.default_chart_type;\n if (def && (column_type === \"integer\" || column_type === \"float\")) {\n const is_series_glyph =\n def === \"bar\" ||\n def === \"line\" ||\n def === \"scatter\" ||\n def === \"area\";\n\n if (is_series_glyph) {\n const has_split = (viewer_config?.split_by?.length ?? 0) > 0;\n if (has_split) {\n fields.push({\n kind: \"Palette\",\n key: \"palette\",\n default: this._themeSeriesPaletteHex(),\n });\n } else {\n const slot = (viewer_config?.columns ?? [])\n .filter((c): c is string => !!c)\n .indexOf(column_name);\n fields.push({\n kind: \"Color\",\n key: \"color\",\n default: this._themeSeriesColorHex(Math.max(0, slot)),\n });\n }\n }\n\n fields.push({\n kind: \"Enum\",\n key: \"chart_type\",\n default: def,\n variants: [\n { value: \"bar\", label: \"Bar\" },\n { value: \"line\", label: \"Line\" },\n { value: \"scatter\", label: \"Scatter\" },\n { value: \"area\", label: \"Area\" },\n ],\n });\n\n const effective_chart_type =\n (current_value?.chart_type as string | undefined) ?? def;\n\n const supports_stack =\n effective_chart_type === \"bar\" ||\n effective_chart_type === \"area\";\n\n if (supports_stack) {\n fields.push({\n kind: \"Bool\",\n key: \"stack\",\n default: supports_stack,\n });\n }\n\n if (is_series_glyph) {\n fields.push({\n kind: \"Bool\",\n key: \"alt_axis\",\n default: false,\n });\n }\n\n // Line / area glyphs can bridge interior nulls by linear\n // interpolation. Bar / scatter ignore the flag.\n const supports_interpolate =\n effective_chart_type === \"line\" ||\n effective_chart_type === \"area\";\n\n if (supports_interpolate) {\n const variants =\n effective_chart_type === \"area\"\n ? [\n { value: \"skip\", label: \"Skip\" },\n { value: \"solid\", label: \"Solid\" },\n ]\n : [\n { value: \"skip\", label: \"Skip\" },\n { value: \"solid\", label: \"Solid\" },\n { value: \"transparent\", label: \"Transparent\" },\n ];\n fields.push({\n kind: \"Enum\",\n key: \"interpolate\",\n default: \"solid\",\n variants,\n });\n }\n }\n\n // Per-column formatter widgets. Surfaced for every chart type so\n // axes / tooltips / legends honor the user's format choice.\n if (column_type === \"integer\" || column_type === \"float\") {\n fields.push({\n kind: \"NumberFormat\",\n default: CHART_NUMBER_DEFAULTS,\n });\n } else if (column_type === \"datetime\") {\n fields.push({\n kind: \"DatetimeFormat\",\n default: CHART_DATETIME_DEFAULTS,\n });\n } else if (column_type === \"date\") {\n fields.push({\n kind: \"DatetimeFormat\",\n default: CHART_DATE_DEFAULTS,\n });\n }\n\n return { fields };\n }\n\n plugin_config_schema(_view_config?: {\n group_by?: string[];\n group_rollup_mode?: string;\n }) {\n const defaults = this._effectiveDefaults();\n const applicable = this._chartType.applicable_plugin_fields;\n const present = new Set(applicable);\n\n const grouped = new Set<PluginConfigField>();\n const groups: Array<Record<string, unknown> & { kind: string }> = [];\n for (const group of PLUGIN_FIELD_GROUPS) {\n const members = group.fields.filter((k) => present.has(k));\n if (members.length >= 1) {\n for (const k of members) {\n grouped.add(k);\n }\n\n groups.push({\n kind: \"Group\",\n key: group.key,\n fields: members.map((k) => fieldSpec(k, defaults)),\n });\n }\n }\n\n const fields: Array<Record<string, unknown> & { kind: string }> =\n applicable\n .filter((k) => !grouped.has(k))\n .map((k) => fieldSpec(k, defaults));\n\n return { fields: [...fields, ...groups] };\n }\n\n private _resolvedTheme(): Theme {\n return resolveThemeFromVars(snapshotThemeVars(this));\n }\n\n private static readonly GRADIENT_PALETTE_FALLBACK_COUNT = 6;\n\n private _themeSeriesPaletteHex(): string {\n const theme = this._resolvedTheme();\n const count =\n theme.seriesPalette.length ||\n HTMLPerspectiveViewerWebGLPluginElement.GRADIENT_PALETTE_FALLBACK_COUNT;\n return colorsToCss(\n resolvePalette(theme.seriesPalette, theme.gradientStops, count),\n );\n }\n\n private _themeSeriesColorHex(idx: number): string {\n const theme = this._resolvedTheme();\n const count = Math.max(theme.seriesPalette.length, idx + 1);\n return vec3ToHexColor(\n resolvePalette(theme.seriesPalette, theme.gradientStops, count)[\n idx\n ],\n );\n }\n\n private _themeGradientStopsSpec(): string {\n return stopsToCss(this._resolvedTheme().gradientStops);\n }\n\n async draw(view: View): Promise<void> {\n // `draw` always indicates a view-level change (pivots, columns,\n // filters, sorts, schema, \u2026) \u2014 invalidate the `domain_mode:\n // \"expand\"` accumulator so the new view's extent starts fresh.\n // `update` (data-only redraw on the same view) shares\n // `_drawImpl` but skips this reset.\n this._renderer?.resetExpandedDomain();\n this._renderer?.resetAllZooms();\n return this._drawImpl(view);\n }\n\n async update(view: View): Promise<void> {\n return this._drawImpl(view);\n }\n\n /**\n * Shared body of `draw` / `update`. No re-entrancy guard: the host\n * serializes every rendering call (`draw`, `update`, `render`,\n * `resize`) and `delete` on its per-renderer draw lock, so this\n * method never overlaps itself or a teardown. The one exception \u2014\n * an external DOM disconnect `delete()`ing the element mid-draw \u2014\n * is absorbed by `RendererTransport`, whose post-`destroy()`\n * requests settle immediately instead of pending forever.\n */\n private async _drawImpl(view: View): Promise<void> {\n let renderer: RendererTransport;\n try {\n renderer = await this._ensureRenderer(view);\n } catch {\n // Renderer was disposed mid-init (element disconnected\n // during the async build) \u2014 nothing to draw.\n return;\n }\n\n renderer.setView(view);\n renderer.setBufferMaxCapacity(this._chartType.max_cells);\n const panel = this.getAttribute(\"slot\") ?? undefined;\n const viewer = this\n .parentElement as HTMLPerspectiveViewerElement | null;\n\n if (viewer === null) {\n return;\n }\n\n const viewerConfig = await viewer.getViewConfig({ panel });\n await renderer.loadAndRender({\n viewerConfig: {\n group_by: viewerConfig?.group_by ?? [],\n split_by: viewerConfig?.split_by ?? [],\n columns: viewerConfig?.columns ?? [],\n },\n options: { float32: true },\n });\n }\n\n async clear(): Promise<void> {\n this._renderer?.clear();\n }\n\n async resize(): Promise<void> {\n // Hidden (an unslotted tab-stack panel, a `display: none` host):\n // the 0\u00D70 rect a hidden element reports would resize the worker\n // canvas to zero \u2014 CLEARING the retained frame, so the next\n // activation repaints from blank (the two-stage tab-switch\n // artifact). Skip instead and keep the last frame for an instant,\n // single-blit reveal \u2014 mirroring the datagrid's guard. The host's\n // activation nudge is also a `resize()`, so a hidden panel's nudge\n // is free by the same check.\n if (!this.isConnected || this.offsetParent == null) {\n return;\n }\n\n // AWAITED to the resized frame's PRESENT (the worker's\n // `resizeAck`) \u2014 the host's presize protocol style-overrides\n // this element to its target box and holds the layout commit on\n // this promise, so resolving at message-post would commit the\n // settings-pane layout against the old-dimensions bitmap (the\n // aspect-ratio warp the datagrid's synchronous resize never\n // shows).\n await this._renderer?.resize();\n }\n\n /**\n * OPTIONAL host presize protocol: render at the TARGET element box\n * `(width, height)` \u2014 the box the host's pending layout commit will\n * produce \u2014 holding the resulting frame offscreen, so nothing on\n * screen changes during the round-trip. Resolves, once the resized\n * frame is staged, to a present closure; the host calls it in the\n * same task as the layout commit, landing geometry and pixels in\n * one paint. Plugins without this method get the host's held\n * style-override presize path instead.\n */\n async presize(width: number, height: number): Promise<(() => void) | void> {\n if (\n !this.isConnected ||\n this.offsetParent == null ||\n !this._renderer ||\n !this._glCanvas\n ) {\n return;\n }\n\n // Target GL-canvas box = its current box shifted by the element's\n // box delta \u2014 the chrome between the element edge and the canvas\n // is constant across a resize.\n const hostRect = this.getBoundingClientRect();\n const glRect = this._glCanvas.getBoundingClientRect();\n return await this._renderer.presize(\n Math.max(0, glRect.width + (width - hostRect.width)),\n Math.max(0, glRect.height + (height - hostRect.height)),\n );\n }\n\n restyle() {\n this._renderer?.invalidateTheme();\n }\n\n /**\n * Clear any active selection state (pinned tooltip) WITHOUT emitting\n * selection events \u2014 the host calls this when a global filter\n * contributed by this panel's selection is removed from the global\n * filter bar, so the pin can't outlive the filter it produced. The\n * transport's `_lastInsertConfig` (remove-set memory) is deliberately\n * RETAINED so a subsequent selection still replaces any leftover\n * clauses rather than accumulating.\n */\n async deselect(): Promise<void> {\n this._renderer?.deselect();\n }\n\n async render(view: View): Promise<Blob> {\n await this._ensureRenderer(view);\n await this.draw(view);\n return this._renderer!.snapshotPng();\n }\n\n restore(config: any, columns_config?: Record<string, any>) {\n if (config?.zoom) {\n this._renderer?.restoreZoom(config.zoom);\n }\n\n // Merge incoming plugin_config on top of the `chart_type`\n // effective defaults so a partial restore (UI emits only\n // changed fields) keeps untouched defaults in place \u2014 and\n // chart-type overrides (e.g. `include_zero=true` for Y Bar /\n // Y Area / X Bar) survive when the host elides their values.\n this._pluginConfig = {\n ...this._effectiveDefaults(),\n ...config,\n };\n\n this._columnsConfig = columns_config ?? {};\n this._renderer?.setPluginConfig(this._pluginConfig);\n this._renderer?.setColumnsConfig(this._columnsConfig);\n }\n\n delete() {\n if (this._rawEventForwarder) {\n this._rawEventForwarder.detach();\n this._rawEventForwarder = null;\n }\n\n if (this._resetClickAbort) {\n this._resetClickAbort.abort();\n this._resetClickAbort = null;\n }\n\n if (this._renderer) {\n this._renderer.destroy();\n this._renderer = null;\n }\n\n this._rendererPromise = null;\n }\n}\n", "// \u250F\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2513\n// \u2503 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588\u2584 \u2580\u2588\u2588\u2588 \u2588 \u2503\n// \u2503 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2584\u2584\u2584\u2584\u2584 \u2584\u2584\u2584\u2584\u2584\u2588 \u2580\u2580\u2580\u2580\u2580\u2588\u2580\u2580\u2580\u2580\u2580 \u2588 \u2580\u2580\u2580\u2580\u2580\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2584 \u2580\u2588 \u2588 \u2580\u2580\u2580\u2580\u2580 \u2503\n// \u2503 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2580\u2580\u2580\u2580 \u2588\u2580\u2588\u2588\u2580\u2580 \u2584\u2584\u2584\u2584\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2584\u2584\u2584\u2584\u2584\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2584\u2584\u2584\u2584\u2584 \u2503\n// \u2503 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2580\u2588\u2584 \u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588 \u2588\u2588\u2588\u258C\u2590\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2588 \u2503\n// \u2523\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u252B\n// \u2503 Copyright (c) 2017, the Perspective Authors. \u2503\n// \u2503 \u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C\u254C \u2503\n// \u2503 This file is part of the Perspective library, distributed under the terms \u2503\n// \u2503 of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). \u2503\n// \u2517\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u251B\n\nimport CHARTS from \"./plugin/charts\";\nimport { HTMLPerspectiveViewerWebGLPluginElement } from \"./plugin/plugin\";\n\nexport type { PerspectiveClickDetail } from \"./event-detail\";\nexport { PerspectiveSelectDetail } from \"./event-detail\";\nexport { registerTileSource } from \"./plugin/plugin\";\nexport { tileSources, type TileSourceSpec } from \"./map/tile-source\";\n\nexport function register(...plugin_names: string[]) {\n const plugins = new Set(\n plugin_names.length > 0\n ? plugin_names\n : CHARTS.map((chart) => chart.name),\n );\n\n const already_registered: string[] = [];\n\n CHARTS.forEach((chart) => {\n if (plugins.has(chart.name)) {\n const tagName = `perspective-viewer-charts-${chart.tag}`;\n\n if (customElements.get(tagName)) {\n already_registered.push(tagName);\n return;\n }\n\n customElements.define(\n tagName,\n class extends HTMLPerspectiveViewerWebGLPluginElement {\n _chartType = chart;\n static _chartType = chart;\n },\n );\n\n customElements.whenDefined(\"perspective-viewer\").then(async () => {\n const Viewer = customElements.get(\"perspective-viewer\") as any;\n await Viewer.registerPlugin(tagName);\n });\n }\n });\n\n if (already_registered.length > 0) {\n console.warn(\n `viewer-charts plugins already registered (${already_registered.length}); skipping duplicate registration (Perspective was loaded more than once on this page).`,\n );\n }\n}\n\nregister();\n"],
5
+ "mappings": "AAuFA,IAAMA,EAAS,gBACTC,EAAO,mBACPC,EAAO,sBACPC,GAAM,mBACNC,EAAM,aACNC,GAAS,CAAC,QAAQ,EAClBC,EAAS,CAAC,QAAQ,EAClBC,EAAS,SACTC,EAAS,SAOR,IAAMC,EAA8C,CACvD,cACA,mBACA,kBACA,mBACA,gBACA,WACA,WACA,gBACJ,EAEaC,EAA+C,CACxD,wBACA,iBACJ,E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AC1C,EAEMC,EAA+B,CAAC,EAEtCF,EAAO,QAASC,GAAU,CACtB,GAAIF,EAAQ,IAAIE,EAAM,IAAI,EAAG,CACzB,IAAME,EAAU,6BAA6BF,EAAM,GAAG,GAEtD,GAAI,eAAe,IAAIE,CAAO,EAAG,CAC7BD,EAAmB,KAAKC,CAAO,EAC/B,MACJ,CAEA,eAAe,OACXA,EACA,cAAcC,CAAwC,CAClD,WAAaH,EACb,OAAO,WAAaA,CACxB,CACJ,EAEA,eAAe,YAAY,oBAAoB,EAAE,KAAK,SAAY,CAE9D,MADe,eAAe,IAAI,oBAAoB,EACzC,eAAeE,CAAO,CACvC,CAAC,CACL,CACJ,CAAC,EAEGD,EAAmB,OAAS,GAC5B,QAAQ,KACJ,6CAA6CA,EAAmB,MAAM,0FAC1E,CAER,CAEAL,GAAS",
6
+ "names": ["SERIES", "CART", "HIER", "FIN", "MAP", "X_AXIS", "Y_AXIS", "SELECT", "TOGGLE", "LEGEND_FIELDS", "TOOLTIP_FIELDS", "SERIES_FIELDS", "SERIES_DEFAULTS", "ZERO_ANCHORED_DEFAULTS", "CARTESIAN_FIELDS", "FIN_FIELDS", "TREE_FIELDS", "HEATMAP_FIELDS", "MAP_BASE_FIELDS", "MAP_SCATTER_FIELDS", "MAP_LINE_FIELDS", "MAP_DENSITY_FIELDS", "DENSITY_FIELDS", "make", "name", "tag", "category", "selectMode", "count", "names", "applicable_plugin_fields", "overrides", "FIN_NAMES", "HIER_NAMES", "SERIES_Y_ROLES", "SERIES_X_ROLES", "CART_ROLES", "HIER_ROLES", "HEATMAP_ROLES", "FIN_ROLES", "MAP_ROLES", "CHARTS", "SERIES", "SELECT", "X_AXIS", "Y_AXIS", "CART", "TOGGLE", "HIER", "FIN", "MAP", "charts_default", "parseCSSColorToVec3", "colorStr", "s", "hex", "m", "vec3ToHexColor", "c", "channel", "x", "DEFAULT_STOPS", "parseCssGradient", "src", "trimmed", "openIdx", "closeIdx", "body", "parts", "depth", "start", "i", "ch", "stops", "startIdx", "firstNorm", "piece", "pctMatch", "color", "offset", "rgb", "parseCSSColorToVec3", "r", "g", "b", "j", "before", "after", "span", "k", "prev", "s", "off", "formatPercent", "offset", "stopsToCss", "stops", "a", "b", "stop", "vec3ToHexColor", "colorsToCss", "colors", "sampleGradient", "t", "last", "lo", "hi", "mid", "span", "u", "perspective_viewer_charts_default", "tile_sources_default", "TemplatedTileSource", "id", "template", "attribution", "tileSize", "maxZoom", "subdomains", "z", "x", "y", "url", "idx", "parseTileSourceSpec", "input", "raw", "str", "key", "v", "label", "placeholder", "rawSubdomains", "s", "num", "dflt", "fnv1a", "h", "i", "TileSourceRegistry", "seed", "entry", "spec", "fingerprint", "TILE_SOURCES", "tile_sources_default", "tileSources", "DEFAULT_FACET_CONFIG", "DEFAULT_PLUGIN_CONFIG", "TILE_SOURCES", "CHART_NUMBER_DEFAULTS", "CHART_DATETIME_DEFAULTS", "CHART_DATE_DEFAULTS", "RawEventForwarder", "element", "emit", "e", "rect", "mx", "my", "PerspectiveSelectDetail", "THEME_VARS", "snapshotThemeVars", "el", "style", "out", "v", "raw", "key", "snapshotFontFaces", "out", "sheet", "rules", "base", "rule", "style", "rawFamily", "rawSrc", "stripOuterQuotes", "resolveSrcUrls", "optional", "prop", "s", "first", "last", "src", "match", "_quote", "url", "DEFAULT_TOOLTIP_STYLE", "NUMERIC_RE", "TOOLTIP_COL_GAP", "DomHostSink", "glCanvas", "parent", "grid", "pos", "bounds", "style", "DEFAULT_TOOLTIP_STYLE", "div", "renderTooltipGridDom", "divW", "divH", "tx", "ty", "cursor", "root", "ncols", "n", "row", "TOOLTIP_COL_GAP", "pct", "rightAlign", "j", "numeric", "NUMERIC_RE", "span", "cell", "RUNTIME_MODE", "RENDER_BLIT_MODE", "renderer_default", "cached", "getWorkerURL", "blob", "renderer_default", "renderer_worker_default", "getWorkerURL", "SHARED_WORKER", "HOST_LISTENERS", "NEXT_SESSION_ID", "getSharedWorker", "url", "renderer_worker_default", "w", "e", "env", "poisoned", "event", "message", "errorMsg", "listener", "RendererTransport", "opts", "resolve", "reject", "workerURL", "RUNTIME_MODE", "bytes", "buf", "glOC", "gridlinesOC", "chromeOC", "rect", "dpr", "themeVars", "snapshotThemeVars", "fontFaces", "snapshotFontFaces", "clientWasm", "clientWorkerURL", "proxyPort", "initMsg", "TILE_SOURCES", "msg", "transfer", "sessionId", "cb", "mod", "channel", "view", "cfg", "n", "id", "promise", "last", "cssWidth", "cssHeight", "err", "staged", "kind", "state", "teardownErr", "entry", "removeConfigs", "insertConfigs", "detail", "PerspectiveSelectDetail", "value", "error", "bitmap", "h", "ev", "node", "parent", "DomHostSink", "clampOpacity", "v", "clampGap", "resolveThemeFromVars", "vars", "get", "prop", "fallback", "gradientSrc", "gradientStops", "parseCssGradient", "seriesPalette", "i", "raw", "parseCSSColorToVec3", "interpolatePalette", "stops", "count", "out", "t", "c", "sampleGradient", "resolvePalette", "discrete", "i", "FACET_CONFIG_DEFAULTS", "DEFAULT_FACET_CONFIG", "registerTileSource", "spec", "TILE_SOURCES", "FIELD_SCHEMAS", "s", "fieldSpec", "key", "defaults", "entry", "PLUGIN_FIELD_GROUPS", "LEGEND_FIELDS", "TOOLTIP_FIELDS", "GLOBAL_STYLES", "sheet", "perspective_viewer_charts_default", "BLIT_MODE", "RENDER_BLIT_MODE", "HTMLPerspectiveViewerWebGLPluginElement", "_HTMLPerspectiveViewerWebGLPluginElement", "value", "DEFAULT_PLUGIN_CONFIG", "container", "c", "view", "p", "r", "renderer", "zoomControls", "RawEventForwarder", "event", "resetBtn", "viewer", "panel", "client", "viewer_class", "clientWasm", "clientWorkerURL", "table", "tableName", "transport", "RendererTransport", "isDefault", "fields", "e", "mode", "column_type", "group", "column_name", "current_value", "viewer_config", "def", "is_series_glyph", "slot", "effective_chart_type", "supports_stack", "variants", "CHART_NUMBER_DEFAULTS", "CHART_DATETIME_DEFAULTS", "CHART_DATE_DEFAULTS", "_view_config", "applicable", "present", "grouped", "groups", "members", "k", "resolveThemeFromVars", "snapshotThemeVars", "theme", "count", "colorsToCss", "resolvePalette", "idx", "vec3ToHexColor", "stopsToCss", "viewerConfig", "width", "height", "hostRect", "glRect", "config", "columns_config", "register", "plugin_names", "plugins", "charts_default", "chart", "already_registered", "tagName", "HTMLPerspectiveViewerWebGLPluginElement"]
7
7
  }